implement pagination

This commit is contained in:
2025-05-28 12:30:08 +03:00
parent 9eaaff9eb2
commit a673210f9f
7 changed files with 215 additions and 30 deletions

View File

@@ -233,7 +233,7 @@ class LeadViewSet(ViewSet):
if is_valid:
try:
lead = serializer.save()
lead: Leads = serializer.save()
# собираем ответ с данными о заявке для фронта
response_data = {
@@ -247,16 +247,31 @@ class LeadViewSet(ViewSet):
}
}
# Тестовая отправка email
# отправляем емаил владельцу маршрута
try:
route_owner_email = route.owner.email
email_subject = f"Новая заявка на перевозку #{lead.id}"
email_content = f"""
<h2>Получена новая заявка на перевозку</h2>
<p>Детали заявки:</p>
<ul>
<li>Номер заявки: {lead.id}</li>
<li>Маршрут: {route.id}</li>
<li>Предложенная цена: {lead.moving_price}</li>
<li>Дата перевозки: {lead.moving_date}</li>
</ul>
"""
email_result = send_email(
to=["timofey.syr1704@yandex.by"],
subject="Тестовое письмо от TripWB",
html_content="<h1>Тест отправки письма</h1><p>Если вы видите это сообщение, значит отправка работает!</p>"
to=[route_owner_email],
subject=email_subject,
html_content=email_content
)
print(f"Email sending result: {email_result}")
if "Ошибка" in email_result:
print(f"Warning: Failed to send email notification: {email_result}")
except Exception as email_error:
print(f"Error sending email: {str(email_error)}")
print(f"Warning: Error while sending email notification: {str(email_error)}")
return Response(response_data, status=status.HTTP_201_CREATED)
except Exception as e: