Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Replace celery @shared_task with @app.task
Cezary Miącz85c285c9d6f4
diff --git a/saleor/account/emails.py b/saleor/account/emails.pyindex 9ed0bc8028..3386c32d8e 100644--- a/saleor/account/emails.py+++ b/saleor/account/emails.py@@ -1,13 +1,13 @@-from celery import shared_taskfrom django.conf import settingsfrom django.urls import reversefrom templated_email import send_templated_mail+from ..celeryconf import appfrom ..core.emails import get_email_base_contextfrom ..core.utils import build_absolute_uri-@shared_taskdef send_password_reset_email(context, recipient):reset_url = build_absolute_uri(reverse(@@ -24,7 +24,7 @@ def send_password_reset_email(context, recipient):context=context)-@shared_taskdef send_account_delete_confirmation_email(token, recipient_email):delete_url = build_absolute_uri(reverse('account:delete-confirm', kwargs={'token': token}))diff --git a/saleor/account/thumbnails.py b/saleor/account/thumbnails.pyindex 3a89d423ed..c95eaadb1b 100644--- a/saleor/account/thumbnails.py+++ b/saleor/account/thumbnails.py@@ -1,10 +1,9 @@-from celery import shared_task-+from ..celeryconf import appfrom ..core.utils import create_thumbnailsfrom .models import User-@shared_taskdef create_user_avatar_thumbnails(user_id):"""Creates thumbnails for user avatar."""create_thumbnails(diff --git a/saleor/core/analytics.py b/saleor/core/analytics.pyindex c0f329ca2e..3dd0e128b7 100644--- a/saleor/core/analytics.py+++ b/saleor/core/analytics.py@@ -1,9 +1,10 @@import uuidimport google_measurement_protocol as ga-from celery import shared_taskfrom django.conf import settings+from ..celeryconf import app+FINGERPRINT_PARTS = ['HTTP_ACCEPT_ENCODING','HTTP_ACCEPT_LANGUAGE',@@ -20,7 +21,7 @@ def get_client_id(request):return uuid.uuid5(UUID_NAMESPACE, name)-@shared_taskdef ga_report(tracking_id, client_id, payloads, extra_headers=None, **extra_data):ga.report(diff --git a/saleor/core/utils/__init__.py b/saleor/core/utils/__init__.pyindex 6f71b37869..7f7f58762f 100644--- a/saleor/core/utils/__init__.py+++ b/saleor/core/utils/__init__.py@@ -4,7 +4,6 @@ from json import JSONEncoderfrom urllib.parse import urljoinfrom babel.numbers import get_territory_currencies-from celery import shared_taskfrom django import formsfrom django.conf import settingsfrom django.contrib.sites.models import Site@@ -23,6 +22,7 @@ from versatileimagefield.image_warmer import VersatileImageFieldWarmerfrom ...account.models import Userfrom ...account.utils import get_random_avatar+from ...celeryconf import appfrom ...core.i18n import COUNTRY_CODE_CHOICESgeoreader = geolite2.reader()@@ -117,7 +117,7 @@ def to_local_currency(price, currency):return None-@shared_taskdef update_conversion_rates_from_openexchangerates():conversion_rates_queryset = update_conversion_rates()return serializers.serialize('json', conversion_rates_queryset)diff --git a/saleor/dashboard/emails.py b/saleor/dashboard/emails.pyindex b9d836fa3a..3021725a6c 100644--- a/saleor/dashboard/emails.py+++ b/saleor/dashboard/emails.py@@ -1,4 +1,3 @@-from celery import shared_taskfrom django.conf import settingsfrom django.contrib.auth.tokens import default_token_generatorfrom django.urls import reverse@@ -7,6 +6,7 @@ from django.utils.http import urlsafe_base64_encodefrom templated_email import send_templated_mailfrom ..account.models import User+from ..celeryconf import appfrom ..core.emails import get_email_base_contextfrom ..core.utils import build_absolute_uri@@ -30,17 +30,17 @@ def _send_set_password_email(pk, template_name):context=ctx)-@shared_taskdef send_set_password_staff_email(staff_pk):_send_set_password_email(staff_pk, 'dashboard/staff/set_password')-@shared_taskdef send_set_password_customer_email(pk):_send_set_password_email(pk, 'dashboard/customer/set_password')-@shared_taskdef send_promote_customer_to_staff_email(staff_pk):staff = User.objects.get(pk=staff_pk)ctx = get_email_base_context()diff --git a/saleor/order/emails.py b/saleor/order/emails.pyindex 4d0a3fd9a4..47702fe044 100644--- a/saleor/order/emails.py+++ b/saleor/order/emails.py@@ -1,9 +1,9 @@-from celery import shared_taskfrom django.conf import settingsfrom django.urls import reversefrom templated_email import send_templated_mailfrom . import events+from ..celeryconf import appfrom ..core.emails import get_email_base_contextfrom ..core.utils import build_absolute_urifrom ..seo.schema.email import get_order_confirmation_markup@@ -52,7 +52,7 @@ def collect_data_for_fullfillment_email(order_pk, template, fulfillment_pk):return email_data-@shared_taskdef send_order_confirmation(order_pk, user_pk=None):"""Sends order confirmation email."""email_data = collect_data_for_email(order_pk, CONFIRM_ORDER_TEMPLATE)@@ -62,7 +62,7 @@ def send_order_confirmation(order_pk, user_pk=None):email_type=events.OrderEventsEmails.ORDER)-@shared_taskdef send_fulfillment_confirmation(order_pk, fulfillment_pk):email_data = collect_data_for_fullfillment_email(order_pk, CONFIRM_FULFILLMENT_TEMPLATE, fulfillment_pk)@@ -84,14 +84,14 @@ def send_fulfillment_confirmation_to_customer(order, fulfillment, user):email_type=events.OrderEventsEmails.DIGITAL_LINKS)-@shared_taskdef send_fulfillment_update(order_pk, fulfillment_pk):email_data = collect_data_for_fullfillment_email(order_pk, UPDATE_FULFILLMENT_TEMPLATE, fulfillment_pk)send_templated_mail(**email_data)-@shared_taskdef send_payment_confirmation(order_pk):"""Sends payment confirmation email."""email_data = collect_data_for_email(order_pk, CONFIRM_PAYMENT_TEMPLATE)diff --git a/saleor/product/tasks.py b/saleor/product/tasks.pyindex d27548b18d..e8ea63c7f0 100644--- a/saleor/product/tasks.py+++ b/saleor/product/tasks.py@@ -1,5 +1,4 @@-from celery import shared_task-+from ..celeryconf import appfrom .models import Attribute, ProductType, ProductVariantfrom .utils.attributes import get_name_from_attributes@@ -23,7 +22,7 @@ def _update_variants_names(instance, saved_attributes):variant.save(update_fields=['name'])-@shared_taskdef update_variants_names(product_type_pk, saved_attributes_ids):instance = ProductType.objects.get(pk=product_type_pk)saved_attributes = Attribute.objects.filter(pk__in=saved_attributes_ids)diff --git a/saleor/product/thumbnails.py b/saleor/product/thumbnails.pyindex 2787e0982e..5280774269 100644--- a/saleor/product/thumbnails.py+++ b/saleor/product/thumbnails.py@@ -1,16 +1,15 @@-from celery import shared_task-+from ..celeryconf import appfrom ..core.utils import create_thumbnailsfrom .models import Category, Collection, ProductImage-@shared_taskdef create_product_thumbnails(image_id):"""Takes a ProductImage model, and creates thumbnails for it."""create_thumbnails(pk=image_id, model=ProductImage, size_set='products')-@shared_taskdef create_category_background_image_thumbnails(category_id):"""Takes a Product model,and creates the background image thumbnails for it."""@@ -19,7 +18,7 @@ def create_category_background_image_thumbnails(category_id):size_set='background_images', image_attr='background_image')-@shared_taskdef create_collection_background_image_thumbnails(collection_id):"""Takes a Collection model,and creates the background image thumbnails for it."""