diff --git a/apps/notification/tasks.py b/apps/notification/tasks.py index 29eeab29..dde665d9 100644 --- a/apps/notification/tasks.py +++ b/apps/notification/tasks.py @@ -107,4 +107,5 @@ def sendgrid_update_recipients(): def send_gift_certificate(user_gift_certificate): user_gift_certificate = UserGiftCertificate.objects.get(id=user_gift_certificate) send_email('Подарочный сертификат от Lil School', user_gift_certificate.user.email, 'notification/email/gift_certificate.html', + inline_images=[('twitter_icon', 'img/twitter.png'), ('fb_icon', 'img/fb.png'), ('instagram_icon', 'img/instagram.png'),], user_gift_certificate=user_gift_certificate, gift_certificate=user_gift_certificate.gift_certificate) diff --git a/apps/notification/templates/notification/email/gift_certificate.html b/apps/notification/templates/notification/email/gift_certificate.html index 32febcf6..f1d8a3f9 100644 --- a/apps/notification/templates/notification/email/gift_certificate.html +++ b/apps/notification/templates/notification/email/gift_certificate.html @@ -92,24 +92,21 @@
+ {% if config.SERVICE_TWITTER_URL %} - - - + + {% endif %} + {% if config.SERVICE_FB_URL %} - - - + + + {% endif %} + {% if config.SERVICE_INSTAGRAM_URL %} + + + {% endif %}
{% endblock content %} diff --git a/apps/notification/utils.py b/apps/notification/utils.py index d556bd96..07510c41 100644 --- a/apps/notification/utils.py +++ b/apps/notification/utils.py @@ -1,16 +1,27 @@ +from django.contrib.staticfiles.storage import staticfiles_storage from twilio.rest import Client - -from django.core.mail import EmailMessage +from django.core.mail import EmailMessage, EmailMultiAlternatives +from anymail.message import attach_inline_image_file from django.conf import settings from django.template.loader import get_template + from project.celery import app @app.task -def send_email(subject, to_email, template_name, attachments=[], **kwargs): - html = get_template(template_name).render(kwargs) - email = EmailMessage(subject, html, to=[to_email], attachments=attachments) - email.content_subtype = 'html' +def send_email(subject, to_email, template_name, attachments=[], inline_images=[], **kwargs): + if inline_images: + email = EmailMultiAlternatives(subject, '', to=[to_email], attachments=attachments) + context = kwargs + for name, path in inline_images: + cid = attach_inline_image_file(email, staticfiles_storage.path(path)) + context[name] = cid + html = get_template(template_name).render(context) + email.attach_alternative(html, "text/html") + else: + html = get_template(template_name).render(kwargs) + email = EmailMessage(subject, html, to=[to_email], attachments=attachments) + email.content_subtype = 'html' email.send() diff --git a/apps/payment/templates/payment/gift_certificate_get.html b/apps/payment/templates/payment/gift_certificate_get.html index 0ae65e3d..6242f060 100644 --- a/apps/payment/templates/payment/gift_certificate_get.html +++ b/apps/payment/templates/payment/gift_certificate_get.html @@ -5,7 +5,8 @@
Бонусы зачислены на ваш счет!
Вы можете оплатить с их помощью курс или онлайн-школу
- Записаться в школу + Записаться в школу Купить курсы
diff --git a/apps/payment/templates/payment/gift_certificate_item.html b/apps/payment/templates/payment/gift_certificate_item.html index f571c1a9..d642cf11 100644 --- a/apps/payment/templates/payment/gift_certificate_item.html +++ b/apps/payment/templates/payment/gift_certificate_item.html @@ -5,22 +5,21 @@
- подарочный сертификат + + {% if user_gift_certificate and not user_gift_certificate.bonuses_sent %} + подарочный сертификат + {% else %}подарочный сертификат{% endif %}
{{ gift_certificate.price|floatformat:"-2" }}₽
{% if user_gift_certificate %} {% if user_gift_certificate.bonuses_sent %}
- - - + Получено
{% else %}
- - - + Ожидает получения
{% endif %} diff --git a/apps/payment/templates/payment/gift_certificates.html b/apps/payment/templates/payment/gift_certificates.html index 3174a91b..5fa4bf2e 100644 --- a/apps/payment/templates/payment/gift_certificates.html +++ b/apps/payment/templates/payment/gift_certificates.html @@ -18,9 +18,12 @@
-
Если вам не совсем удобно заниматься с нами каждый день в нашей онлайн-школе, специально для вас мы - делаем отдельные уроки в записи, которые вы можете проходить, когда вам будет удобно.

- Учите и развивайте креативное мышление когда и где угодно +
Подарочный сертификат Lil City - отличный презент на любой праздник.
+А также сертификат можно подарить без повода - развитие
творческого потенциала всегда уместно и актуально. +При покупке подарочного сертификата мы высылаем письмо,
+где будет уникальный код и уникальная ссылка. Письмо или ссылку
+на него вы можете переслать другому. Сертификатом можно
+воспользоваться, перейдя по ссылке.
Сертификаты
diff --git a/apps/payment/views.py b/apps/payment/views.py index f10cc218..02a2b874 100644 --- a/apps/payment/views.py +++ b/apps/payment/views.py @@ -377,7 +377,10 @@ class GiftCertificateGetView(TemplateView): template_name = 'payment/gift_certificate_get.html' def get(self, request, slug, *args, **kwargs): - ugs = get_object_or_404(UserGiftCertificate, pk=short_url.decode_url(slug)) + try: + ugs = get_object_or_404(UserGiftCertificate, pk=short_url.decode_url(slug)) + except: + raise Http404() if UserBonus.objects.filter(payment=ugs.payment).exists(): raise Http404() bonuses = UserBonus.objects.create(user=request.user, amount=ugs.gift_certificate.price, diff --git a/apps/user/templates/user/profile.html b/apps/user/templates/user/profile.html index 3970b922..b8e19a19 100644 --- a/apps/user/templates/user/profile.html +++ b/apps/user/templates/user/profile.html @@ -2,8 +2,10 @@
- Редактировать - Ввести код +
{% thumbnail user.photo "120x120" crop="center" as im %} diff --git a/project/templates/blocks/popup_enter_gift_code.html b/project/templates/blocks/popup_enter_gift_code.html index 8cbf2b2d..7ad5c256 100644 --- a/project/templates/blocks/popup_enter_gift_code.html +++ b/project/templates/blocks/popup_enter_gift_code.html @@ -8,19 +8,16 @@
diff --git a/project/templates/blocks/popup_gift_certificate.html b/project/templates/blocks/popup_gift_certificate.html index a9308a2d..f1d551a8 100644 --- a/project/templates/blocks/popup_gift_certificate.html +++ b/project/templates/blocks/popup_gift_certificate.html @@ -8,8 +8,10 @@