diff --git a/artel/store/models.py b/artel/store/models.py index ad9890b..1ab34f0 100644 --- a/artel/store/models.py +++ b/artel/store/models.py @@ -225,7 +225,6 @@ class Product(ClusterableModel): return main_image return self.product_images.first() - @property def tags(self): return self.template.tags.all() diff --git a/artel/store/tasks.py b/artel/store/tasks.py new file mode 100644 index 0000000..94e28f8 --- /dev/null +++ b/artel/store/tasks.py @@ -0,0 +1,30 @@ +import logging +from django.conf import settings + +from mailings.models import OutgoingEmail +from store.models import Product + + +logger = logging.getLogger(__name__) + +# TODO - those should be modified to be celery tasks + +def send_produt_request_email(variant_pk: int): + try: + variant = Product.objects.get(pk=variant_pk) + except Product.DoesNotExist: + logger.exception(f"Product with pk={variant_pk} does not exist") + + try: + send = OutgoingEmail.objects.send( + template_name="product_request", + subject="Zapytanie o produkt", + recipient=variant.template.author.email, + context={"product": variant}, + sender=settings.DEFAULT_FROM_EMAIL + ) + except Exception as e: + logger.exception(f"Could not send email for variant pk={variant_pk}, exception: {e} has occured") + else: + if not send: + logger.exception(f"Could not send email for variant pk={variant_pk}") diff --git a/artel/store/templates/store/configure_product_summary.html b/artel/store/templates/store/configure_product_summary.html index 6707231..f9ff2b2 100644 --- a/artel/store/templates/store/configure_product_summary.html +++ b/artel/store/templates/store/configure_product_summary.html @@ -18,10 +18,6 @@ -
-