Merge pull request 'Не понятная жуть с импортами' (#20) from fix_test into main
Some checks failed
Auto-update README / update-readme (push) Has been cancelled

Reviewed-on: #20
This commit is contained in:
Николай Сердюк 2026-06-19 18:55:56 +03:00
commit 9d4e1729b4

View File

@ -261,13 +261,13 @@ def send_order_notification_async(order):
"""Выбирает способ отправки в зависимости от DEBUG.""" """Выбирает способ отправки в зависимости от DEBUG."""
if settings.DEBUG: if settings.DEBUG:
# Используем background-tasks # Используем background-tasks
from ..tasks import send_order_notification_background from programmer.tasks import send_order_notification_background
send_order_notification_background(order.id) send_order_notification_background(order.id)
return True # задача поставлена в очередь return True # задача поставлена в очередь
else: else:
# Используем Celery # Используем Celery
try: try:
from ..tasks import send_order_notification_celery from programmer.tasks import send_order_notification_celery
send_order_notification_celery.delay(order.id) send_order_notification_celery.delay(order.id)
return True return True
except (ImportError, AttributeError): except (ImportError, AttributeError):
@ -278,13 +278,13 @@ def send_order_notification_async(order):
def send_multiple_order_notifications_async(orders): def send_multiple_order_notifications_async(orders):
if settings.DEBUG: if settings.DEBUG:
from ..tasks import send_multiple_order_notifications_background from programmer.tasks import send_multiple_order_notifications_background
order_ids = list(orders.values_list('id', flat=True)) order_ids = list(orders.values_list('id', flat=True))
send_multiple_order_notifications_background(order_ids) send_multiple_order_notifications_background(order_ids)
return len(order_ids) return len(order_ids)
else: else:
try: try:
from ..tasks import send_multiple_order_notifications_celery from programmer.tasks import send_multiple_order_notifications_celery
order_ids = list(orders.values_list('id', flat=True)) order_ids = list(orders.values_list('id', flat=True))
send_multiple_order_notifications_celery.delay(order_ids) send_multiple_order_notifications_celery.delay(order_ids)
return len(order_ids) return len(order_ids)