diff --git a/apps/course/templates/course/course.html b/apps/course/templates/course/course.html index 7ab898b1..72b3df68 100644 --- a/apps/course/templates/course/course.html +++ b/apps/course/templates/course/course.html @@ -29,17 +29,22 @@ Редактировать {% endif %} {% if course.author != request.user and not paid and course.price %} - + {% if pending %}ОЖИДАЕТСЯ ПОДТВЕРЖДЕНИЕ ОПЛАТЫ{% else %}КУПИТЬ КУРС{% endif %} + {% if not paid %} + Подарить другу {% endif %} - >{% if pending %}ОЖИДАЕТСЯ ПОДТВЕРЖДЕНИЕ ОПЛАТЫ{% else %}КУПИТЬ КУРС{% endif %} + {% endif %}
Редактировать {% endif %} {% if not paid and course.price and not has_full_access %} - + {% if pending %}ОЖИДАЕТСЯ ПОДТВЕРЖДЕНИЕ ОПЛАТЫ{% else %}КУПИТЬ КУРС{% endif %} + {% if not paid %} + Подарить другу {% endif %} - >{% if pending %}ОЖИДАЕТСЯ ПОДТВЕРЖДЕНИЕ ОПЛАТЫ{% else %}КУПИТЬ КУРС{% endif %} +
{% endif %}
Поздравляем с успешной +

Поздравляем с успешной покупкой!

Вы получаете {{ gift_certificate.price }} лиликов на счет! 1 LIL = 1 руб.
@@ -41,10 +42,11 @@

Чтобы воспользоваться сертификатом, перейдите по ссылке
- {% url 'gift-certificate-get' gift_certificate.code %} + "> + {% setting 'MAIN_HOST' %}{% url 'index' %}?gift-certificate={{ user_gift_certificate.code }}
Или воспользуйтесь сертификатом, введя уникальный код на в разделе @@ -54,14 +56,14 @@
Ваш код
@@ -79,4 +81,35 @@ "> Вы так же можете отправить это письмо, ссылку или код вашему другу, чтобы подарить ему этот сертификат.
+
+ Присоединяйтесь к нам! +
+
+ + + + + + + + + + +
+ {% endblock content %} diff --git a/apps/payment/models.py b/apps/payment/models.py index 34e2765c..f7623038 100644 --- a/apps/payment/models.py +++ b/apps/payment/models.py @@ -247,12 +247,12 @@ class Payment(PolymorphicModel): else: author_balance.amount = self.amount author_balance.save() - if isinstance(self, UserGiftCertificate) and self.is_paid(): + if isinstance(self, GiftCertificatePayment) and self.is_paid(): ugs, created = UserGiftCertificate.objects.get_or_create(user=self.user, gift_certificate=self.gift_certificate, payment=self) if created: from apps.notification.tasks import send_gift_certificate - send_gift_certificate.delay(ugs) + send_gift_certificate(ugs.id) # Если юзер реферал и нет платежа, где применялась скидка if hasattr(self.user, 'referral') and not self.user.referral.payment and self.is_paid(): # Платеж - как сигнал, что скидка применилась diff --git a/apps/payment/templates/payment/gift_certificate_get.html b/apps/payment/templates/payment/gift_certificate_get.html new file mode 100644 index 00000000..0ae65e3d --- /dev/null +++ b/apps/payment/templates/payment/gift_certificate_get.html @@ -0,0 +1,14 @@ +{% extends "templates/lilcity/index.html" %} {% load static %} {% block content %} +
+
+
+
Бонусы зачислены на ваш счет!
+
Вы можете оплатить с их помощью курс или онлайн-школу
+ +
+
+
+{% endblock content %} diff --git a/apps/payment/templates/payment/gift_certificate_item.html b/apps/payment/templates/payment/gift_certificate_item.html index f77528d0..f571c1a9 100644 --- a/apps/payment/templates/payment/gift_certificate_item.html +++ b/apps/payment/templates/payment/gift_certificate_item.html @@ -10,9 +10,19 @@
{% if user_gift_certificate %} {% if user_gift_certificate.bonuses_sent %} -
Получено
+
+ + + + Получено +
{% else %} -
Ожидает получения
+
+ + + + Ожидает получения +
{% endif %} {% else %} Если вам не совсем удобно заниматься с нами каждый день в нашей онлайн-школе, специально для вас мы делаем отдельные уроки в записи, которые вы можете проходить, когда вам будет удобно.

Учите и развивайте креативное мышление когда и где угодно +
Сертификаты
diff --git a/apps/payment/views.py b/apps/payment/views.py index a25cc124..f10cc218 100644 --- a/apps/payment/views.py +++ b/apps/payment/views.py @@ -12,7 +12,7 @@ import calendar from django.contrib import messages from django.contrib.auth.decorators import login_required -from django.http import HttpResponse +from django.http import HttpResponse, Http404 from django.shortcuts import redirect, get_object_or_404 from django.views.generic import View, TemplateView, DetailView from django.views.decorators.csrf import csrf_exempt @@ -365,17 +365,25 @@ class GiftCertificateBuySuccessView(TemplateView): template_name = 'payment/gift_certificate_payment_success.html' def get(self, request, payment_id=None, *args, **kwargs): - # print(GiftCertificatePayment.objects.get(id=payment_id)) - gift_certificate_payment = get_object_or_404(GiftCertificatePayment, pk=payment_id) + try: + GiftCertificatePayment.objects.get(id=payment_id) + except: + raise Http404() return self.render_to_response(context={'gift_certificate': True}) +@method_decorator(login_required, name='dispatch') 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)) - return self.render_to_response(context={'gift_certificate': ugs.gift_certificate, 'user_gift_certificate': ugs}) + if UserBonus.objects.filter(payment=ugs.payment).exists(): + raise Http404() + bonuses = UserBonus.objects.create(user=request.user, amount=ugs.gift_certificate.price, + payment=ugs.payment) + ugs.bonuses_sent = bonuses + ugs.save() + context = self.get_context_data(**kwargs) + return self.render_to_response(context) - def post(self, request, slug, *args, **kwargs): - pass diff --git a/apps/school/templates/summer/promo.html b/apps/school/templates/summer/promo.html index 8b1ed12e..7d12fac4 100644 --- a/apps/school/templates/summer/promo.html +++ b/apps/school/templates/summer/promo.html @@ -20,6 +20,9 @@ {% if is_purchased %}ваша подписка истекает {{ subscription_ends_humanize }}
перейти к оплате{% endif %}
+ {% if not is_purchased and not is_purchased_future %} + Подарить другу + {% endif %}
diff --git a/apps/user/templates/user/profile.html b/apps/user/templates/user/profile.html index 81eee428..3970b922 100644 --- a/apps/user/templates/user/profile.html +++ b/apps/user/templates/user/profile.html @@ -3,6 +3,7 @@
Редактировать + Ввести код
{% thumbnail user.photo "120x120" crop="center" as im %} @@ -91,10 +92,10 @@ Перейти в онлайн-школу
{% endif %} - {% if gift_certificates.exists %} + {% if user_gift_certificates.exists %} {% for ugs in user_gift_certificates %} {% cycle 'theme_pink2' 'theme_cyan' 'theme_violet2' as theme_color silent %} - {% include "payment/gift_certificate_item.html" gift_certificate=ugs.gift_certificate user_gift_certificate=ugs %} + {% include "payment/gift_certificate_item.html" with gift_certificate=ugs.gift_certificate user_gift_certificate=ugs %} {% endfor %} {% endif %} {% if paid.exists %} diff --git a/project/templates/blocks/popup_enter_gift_code.html b/project/templates/blocks/popup_enter_gift_code.html new file mode 100644 index 00000000..8cbf2b2d --- /dev/null +++ b/project/templates/blocks/popup_enter_gift_code.html @@ -0,0 +1,27 @@ +{% load static %} + diff --git a/project/templates/blocks/popup_gift_certificate.html b/project/templates/blocks/popup_gift_certificate.html index 6416acfa..a9308a2d 100644 --- a/project/templates/blocks/popup_gift_certificate.html +++ b/project/templates/blocks/popup_gift_certificate.html @@ -6,10 +6,12 @@ -