Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Add delay to Celery tasks, remove unused task

Patryk Zawadzkid3524a0cd023
diff --git a/saleor/core/analytics.py b/saleor/core/analytics.py
index 48c8c08dc1..c0f329ca2e 100644
--- a/saleor/core/analytics.py
+++ b/saleor/core/analytics.py
@@ -31,7 +31,7 @@ def ga_report(
def _report(client_id, payloads, extra_headers=None, **extra_data):
tracking_id = getattr(settings, 'GOOGLE_ANALYTICS_TRACKING_ID', None)
if tracking_id and client_id:
- ga_report(
+ ga_report.delay(
tracking_id, client_id, payloads, extra_headers=extra_headers,
**extra_data)
diff --git a/saleor/dashboard/customer/views.py b/saleor/dashboard/customer/views.py
index 92329a7599..ca9779d227 100644
--- a/saleor/dashboard/customer/views.py
+++ b/saleor/dashboard/customer/views.py
@@ -61,7 +61,7 @@ def customer_create(request):
form.save()
msg = pgettext_lazy(
'Dashboard message', 'Added customer %s') % customer
- send_set_password_email(customer)
+ send_set_password_email.delay(customer)
messages.success(request, msg)
return redirect('dashboard:customer-details', pk=customer.pk)
ctx = {'form': form, 'customer': customer}
diff --git a/saleor/dashboard/staff/views.py b/saleor/dashboard/staff/views.py
index 70ed69830a..4713fa0f2b 100644
--- a/saleor/dashboard/staff/views.py
+++ b/saleor/dashboard/staff/views.py
@@ -63,9 +63,9 @@ def staff_create(request):
'Dashboard message', 'Added staff member %s') % (staff,)
messages.success(request, msg)
if created:
- send_set_password_email(staff)
+ send_set_password_email.delay(staff)
else:
- send_promote_customer_to_staff_email(staff)
+ send_promote_customer_to_staff_email.delay(staff)
return redirect('dashboard:staff-list')
ctx = {'form': form}
return TemplateResponse(request, 'dashboard/staff/detail.html', ctx)
diff --git a/saleor/order/emails.py b/saleor/order/emails.py
index 1842edfd85..63a0fe5257 100644
--- a/saleor/order/emails.py
+++ b/saleor/order/emails.py
@@ -12,7 +12,6 @@ CONFIRM_ORDER_TEMPLATE = 'order/confirm_order'
CONFIRM_FULFILLMENT_TEMPLATE = 'order/confirm_fulfillment'
UPDATE_FULFILLMENT_TEMPLATE = 'order/update_fulfillment'
CONFIRM_PAYMENT_TEMPLATE = 'order/payment/confirm_payment'
-CONFIRM_NOTE_TEMPLATE = 'order/note/confirm_note'
def collect_data_for_email(order_pk, template):
@@ -72,10 +71,3 @@ def send_payment_confirmation(order_pk):
"""Sends payment confirmation email."""
email_data = collect_data_for_email(order_pk, CONFIRM_PAYMENT_TEMPLATE)
send_templated_mail(**email_data)
-
-
-@shared_task
-def send_note_confirmation(order_pk):
- """Notifies customer, when new note was added to an order."""
- email_data = collect_data_for_email(order_pk, CONFIRM_NOTE_TEMPLATE)
- send_templated_mail(**email_data)
diff --git a/templates/templated_email/order/note/confirm_note.email b/templates/templated_email/order/note/confirm_note.email
deleted file mode 100644
index 7b1ea8f202..0000000000
--- a/templates/templated_email/order/note/confirm_note.email
+++ /dev/null
@@ -1,23 +0,0 @@
-{% load i18n %}
-
-{% block subject %}
- {% trans "New note has been added to your order" context "Note confirmation email subject" %}
-{% endblock %}
-
-{% block plain %}
-{% blocktrans context "Note confirmation email text" %}
-Hi!
-
-A new note has been added to your order. To see details please visit:
-{{ order_details_url }}
-
-This is an automatically generated email, please do not reply.
-
-Sincerely,
-{{ site_name }}
-{% endblocktrans %}
-{% endblock %}
-
-{% block html %}
-{% include 'templated_email/compiled/confirm_note.html' %}
-{% endblock %}
diff --git a/templates/templated_email/source/confirm_note.mjml b/templates/templated_email/source/confirm_note.mjml
deleted file mode 100644
index 581af91d26..0000000000
--- a/templates/templated_email/source/confirm_note.mjml
+++ /dev/null
@@ -1,24 +0,0 @@
-<mjml>
- <mj-head>
- <mj-include path="./shared/styles.mjml" />
- </mj-head>
- <mj-body>
- <mj-raw>
- {% load i18n %}
- </mj-raw>
- <mj-include path="./shared/header.mjml" />
- <mj-section>
- <mj-column>
- <mj-text font-size="16px">
- {% trans "Hi!" context "Note confirmation e-mail text" %}
- </mj-text>
- <mj-text>
- {% blocktrans trimmed context "Note confirmation e-mail text" %}
- A new note has been added to your order. To see details please visit: <a href="{{ order_details_url }}">{{ order_details_url }}</a>
- {% endblocktrans %}
- </mj-text>
- </mj-column>
- </mj-section>
- <mj-include path="./shared/footer.mjml" />
- </mj-body>
-</mjml>
diff --git a/tests/test_emails.py b/tests/test_emails.py
index ff216f5c33..dbc403d118 100644
--- a/tests/test_emails.py
+++ b/tests/test_emails.py
@@ -57,7 +57,6 @@ def test_collect_data_for_email(order):
@pytest.mark.parametrize('send_email,template', [
(emails.send_payment_confirmation, emails.CONFIRM_PAYMENT_TEMPLATE),
- (emails.send_note_confirmation, emails.CONFIRM_NOTE_TEMPLATE),
(emails.send_order_confirmation, emails.CONFIRM_ORDER_TEMPLATE)])
@mock.patch('saleor.order.emails.send_templated_mail')
def test_send_emails(mocked_templated_email, order, template, send_email):