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