From be36a86b6762a1aed031ae421ef9e775286bb744 Mon Sep 17 00:00:00 2001 From: gzbender Date: Tue, 20 Aug 2019 21:11:58 +0300 Subject: [PATCH 01/10] =?UTF-8?q?=D0=9E=D0=BF=D0=BB=D0=B0=D1=82=D0=B0=20?= =?UTF-8?q?=D0=B1=D0=BE=D0=BD=D1=83=D1=81=D0=B0=D0=BC=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/payment/templates/payment/pay.html | 10 ++++++ .../templates/payment/paymentwall_widget.html | 12 ++----- apps/payment/views.py | 34 ++++++++++++------- 3 files changed, 35 insertions(+), 21 deletions(-) create mode 100644 apps/payment/templates/payment/pay.html diff --git a/apps/payment/templates/payment/pay.html b/apps/payment/templates/payment/pay.html new file mode 100644 index 00000000..e25caa87 --- /dev/null +++ b/apps/payment/templates/payment/pay.html @@ -0,0 +1,10 @@ +{% extends "templates/lilcity/index.html" %} {% load static %} {% block content %} +{% if school and request.user.bonus %} + +{% endif %} +
+
+ {% include "./paymentwall_widget.html" %} +
+
+{% endblock content %} diff --git a/apps/payment/templates/payment/paymentwall_widget.html b/apps/payment/templates/payment/paymentwall_widget.html index bdde28e0..08fc4c5f 100644 --- a/apps/payment/templates/payment/paymentwall_widget.html +++ b/apps/payment/templates/payment/paymentwall_widget.html @@ -1,9 +1,3 @@ -{% extends "templates/lilcity/index.html" %} {% load static %} {% block content %} -
-
- {% autoescape off %} - {{ widget }} - {% endautoescape %} -
-
-{% endblock content %} +{% autoescape off %} +{{ widget }} +{% endautoescape %} diff --git a/apps/payment/views.py b/apps/payment/views.py index 8eb30777..688287c2 100644 --- a/apps/payment/views.py +++ b/apps/payment/views.py @@ -119,7 +119,8 @@ class CourseBuyView(TemplateView): @method_decorator(login_required, name='dispatch') class SchoolBuyView(TemplateView): - template_name = 'payment/paymentwall_widget.html' + # template_name = 'payment/paymentwall_widget.html' + template_name = 'payment/pay.html' def get(self, request, *args, **kwargs): host = urlsplit(self.request.META.get('HTTP_REFERER')) @@ -128,30 +129,39 @@ class SchoolBuyView(TemplateView): roistat_visit = request.COOKIES.get('roistat_visit', None) date_start = request.GET.get('date_start') duration = request.GET.get('duration') + payment_id = request.GET.get('payment_id') package = get_object_or_404(Package, duration=duration) date_start = date_start and datetime.datetime.strptime(date_start, '%Y-%m-%d').date() or now().date() - amount_data = SchoolPayment.calc_amount(package=package, user=request.user, date_start=date_start) - school_payment = SchoolPayment.objects.create( - user=request.user, - weekdays=amount_data.get('weekdays'), - roistat_visit=roistat_visit, - date_start=amount_data.get('date_start'), - date_end=amount_data.get('date_end'), - package=package, - ) + if payment_id: + school_payment = get_object_or_404(SchoolPayment, id=payment_id) + else: + amount_data = SchoolPayment.calc_amount(package=package, user=request.user, date_start=date_start) + school_payment = SchoolPayment.objects.create( + user=request.user, + weekdays=amount_data.get('weekdays'), + roistat_visit=roistat_visit, + date_start=amount_data.get('date_start'), + date_end=amount_data.get('date_end'), + package=package, + ) if use_bonuses and request.user.bonus: if request.user.bonus >= school_payment.amount: bonus = UserBonus.objects.create(amount= -school_payment.amount, user=request.user, payment=school_payment) school_payment.amount = 0 school_payment.status = Pingback.PINGBACK_TYPE_REGULAR else: - bonus = UserBonus.objects.create(amount= -request.user.bonus, user=request.user, - payment=school_payment) school_payment.amount -= request.user.bonus + bonus = UserBonus.objects.create(amount= -request.user.bonus, user=request.user, + payment=school_payment) school_payment.bonus = bonus school_payment.save() if school_payment.is_paid(): return redirect(reverse_lazy('payment-success')) + if payment_id and school_payment.bonus and not use_bonuses: + bonus = school_payment.bonus + school_payment.amount += school_payment.bonus + school_payment.bonus = None + bonus.delete() product = Product( f'school_{school_payment.id}', school_payment.amount, From ca55f8af19f3829edea4fa72f6e8b4165f17aad4 Mon Sep 17 00:00:00 2001 From: gzbender Date: Tue, 20 Aug 2019 21:52:01 +0300 Subject: [PATCH 02/10] =?UTF-8?q?=D0=9E=D1=82=D0=BA=D1=80=D1=8B=D1=82?= =?UTF-8?q?=D0=B8=D0=B5=20=D1=88=D0=BA=D0=BE=D0=BB=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/school/templates/blocks/schedule_item.html | 2 ++ apps/school/templates/summer/buy.html | 7 ++++--- project/templates/blocks/header.html | 14 +++++++------- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/apps/school/templates/blocks/schedule_item.html b/apps/school/templates/blocks/schedule_item.html index 66e80182..86c5d301 100644 --- a/apps/school/templates/blocks/schedule_item.html +++ b/apps/school/templates/blocks/schedule_item.html @@ -20,9 +20,11 @@ {% include './open_lesson.html' %} {% endif %} {% else %} + {% comment %} {% if not is_purchased_future and is_drawing_camp %} {% include './day_pay_btn.html' %} {% endif %} + {% endcomment %} {% endif %} {% if not is_purchased and not request.user_agent.is_mobile and school_schedule.trial_lesson %} Пробный урок diff --git a/apps/school/templates/summer/buy.html b/apps/school/templates/summer/buy.html index a7a7cf71..8419f130 100644 --- a/apps/school/templates/summer/buy.html +++ b/apps/school/templates/summer/buy.html @@ -2,12 +2,13 @@ - + @@ -45,11 +45,11 @@ - + + + + +
ВИДЕО-КУРСЫ
From 4d12008a9e30c1f03c344ba375dc5a80d1537fee Mon Sep 17 00:00:00 2001 From: gzbender Date: Wed, 21 Aug 2019 15:36:55 +0300 Subject: [PATCH 03/10] =?UTF-8?q?=D0=91=D0=B0=D0=B3=D0=B8=20=D1=81=D1=82?= =?UTF-8?q?=D1=80=D0=B0=D0=BD=D0=B8=D1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/school/templates/blocks/schedule_item.html | 5 +---- web/src/sass/_common.sass | 4 +--- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/apps/school/templates/blocks/schedule_item.html b/apps/school/templates/blocks/schedule_item.html index 86c5d301..1ce333a3 100644 --- a/apps/school/templates/blocks/schedule_item.html +++ b/apps/school/templates/blocks/schedule_item.html @@ -6,9 +6,6 @@
{{ school_schedule }} - {% if not is_purchased and request.user_agent.is_mobile and school_schedule.trial_lesson %} - Пробный урок - {% endif %}
{% if is_purchased and live_lesson %}
{% if request.user_agent.is_mobile %}{{ live_lesson.date|date:"j b" }}{% else %}{{ live_lesson.date|date:"j E" }}{% endif %}
@@ -26,7 +23,7 @@ {% endif %} {% endcomment %} {% endif %} - {% if not is_purchased and not request.user_agent.is_mobile and school_schedule.trial_lesson %} + {% if not is_purchased and school_schedule.trial_lesson %} Пробный урок {% endif %}
diff --git a/web/src/sass/_common.sass b/web/src/sass/_common.sass index 2b362379..badaeaf4 100755 --- a/web/src/sass/_common.sass +++ b/web/src/sass/_common.sass @@ -4362,9 +4362,7 @@ a.grey-link display: inline-block margin-top: 10px +m - position: absolute; - width: 120px; - margin-top: 6px; + margin-top: 0 &__time margin: 15px 0 opacity: .5 From b16ca882c9fa9abc19a83854b4420ac0052c379e Mon Sep 17 00:00:00 2001 From: gzbender Date: Thu, 22 Aug 2019 19:16:50 +0300 Subject: [PATCH 04/10] =?UTF-8?q?=D0=9E=D0=BF=D0=BB=D0=B0=D1=82=D0=B0=20?= =?UTF-8?q?=D0=B1=D0=BE=D0=BD=D1=83=D1=81=D0=B0=D0=BC=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/payment/templates/payment/pay.html | 27 +++++++++++++++++++++---- apps/payment/views.py | 16 ++++++++++----- web/src/js/pages/pay.js | 11 ++++++++++ web/src/sass/_common.sass | 21 +++++++++++++++++++ web/webpack.config.js | 1 + 5 files changed, 67 insertions(+), 9 deletions(-) create mode 100644 web/src/js/pages/pay.js diff --git a/apps/payment/templates/payment/pay.html b/apps/payment/templates/payment/pay.html index e25caa87..ec26e9ca 100644 --- a/apps/payment/templates/payment/pay.html +++ b/apps/payment/templates/payment/pay.html @@ -1,10 +1,29 @@ -{% extends "templates/lilcity/index.html" %} {% load static %} {% block content %} -{% if school and request.user.bonus %} +{% extends "templates/lilcity/index.html" %} +{% load static %} +{% load rupluralize from plural %} -{% endif %} +{% block content %}
- {% include "./paymentwall_widget.html" %} + {% if school and request.user.bonus and not payment.bonus %} + {% if request.user.bonus >= payment.amount %} + Оплатить бонусами +

или купить онлайн

+ {% else %} +

Для оплаты части стоимости вы можете использовать бонусы

+ + {% endif %} + {% endif %} +
+ {% include "./paymentwall_widget.html" %} +
{% endblock content %} + +{% block foot %} + +{% endblock foot %} diff --git a/apps/payment/views.py b/apps/payment/views.py index 688287c2..34eb6bc2 100644 --- a/apps/payment/views.py +++ b/apps/payment/views.py @@ -14,7 +14,7 @@ from django.http import HttpResponse, Http404 from django.shortcuts import redirect, get_object_or_404 from django.views.generic import View, TemplateView from django.views.decorators.csrf import csrf_exempt -from django.urls import reverse_lazy +from django.urls import reverse from django.utils.decorators import method_decorator from django.utils.timezone import now @@ -156,7 +156,7 @@ class SchoolBuyView(TemplateView): school_payment.bonus = bonus school_payment.save() if school_payment.is_paid(): - return redirect(reverse_lazy('payment-success')) + return redirect('%s?duration=%s' % (reverse('payment-success'), duration)) if payment_id and school_payment.bonus and not use_bonuses: bonus = school_payment.bonus school_payment.amount += school_payment.bonus @@ -178,11 +178,17 @@ class SchoolBuyView(TemplateView): 'evaluation': 1, 'demo': 1, 'test_mode': 1, - 'success_url': host + str(reverse_lazy('payment-success')) + '?duration=%s' % duration, - 'failure_url': host + str(reverse_lazy('payment-error')), + 'success_url': host + reverse('payment-success') + '?duration=%s' % duration, + 'failure_url': host + reverse('payment-error'), } ) - return self.render_to_response(context={'widget': widget.get_html_code()}) + if self.request.is_ajax(): + self.template_name = 'payment/paymentwall_widget.html' + return self.render_to_response(context={ + 'widget': widget.get_html_code({'height': '400'}), + 'school': True, + 'payment': school_payment, + }) @method_decorator(login_required, name='dispatch') diff --git a/web/src/js/pages/pay.js b/web/src/js/pages/pay.js new file mode 100644 index 00000000..ea217e10 --- /dev/null +++ b/web/src/js/pages/pay.js @@ -0,0 +1,11 @@ +import $ from 'jquery'; + +$(document).ready(function () { + const $useBonuses = $('#use-bonuses-checkbox input'); + const $widget = $('#pw-widget'); + $useBonuses.change(e => { + $.get($useBonuses.data('url') + '&use_bonuses=' + ($useBonuses.prop('checked') ? 1 : '')).then(response => { + $widget.html(response); + }); + }); +}); diff --git a/web/src/sass/_common.sass b/web/src/sass/_common.sass index badaeaf4..8c5ca684 100755 --- a/web/src/sass/_common.sass +++ b/web/src/sass/_common.sass @@ -5238,6 +5238,27 @@ a width: 24px margin-bottom: -6px + +.pw-widget + display: inline-block + position: relative + + &:before + content: ' ' + position: absolute + top: 30% + left: 50% + width: 50px + height: 50px + border-left: 3px solid transparent + border: 3px solid #B5B5B5 + border-right: none + border-top: none + border-bottom: none + z-index: -1 + border-radius: 50% + animation: loading .6s infinite linear + .mobile-hide +m display: none diff --git a/web/webpack.config.js b/web/webpack.config.js index afdec32d..24404936 100644 --- a/web/webpack.config.js +++ b/web/webpack.config.js @@ -17,6 +17,7 @@ module.exports = { liveLesson: "./src/js/pages/live-lesson.js", freeLessons: "./src/js/pages/free-lessons.js", userGalleryEdit: "./src/js/pages/user-gallery-edit.js", + pay: "./src/js/pages/pay.js", mixpanel: "./src/js/third_party/mixpanel-2-latest.js", sprite: glob('./src/icons/*.svg'), images: glob('./src/img/*.*'), From 20ffcef9e1b89b4cd3fc43a6f4e15656ddb6fdbf Mon Sep 17 00:00:00 2001 From: gzbender Date: Thu, 22 Aug 2019 19:41:50 +0300 Subject: [PATCH 05/10] =?UTF-8?q?=D0=9E=D0=BD=D0=BB=D0=B0=D0=B9=D0=BD=20?= =?UTF-8?q?=D1=88=D0=BA=D0=BE=D0=BB=D0=B0=20=D0=BD=D0=B0=20=D0=BF=D0=BE?= =?UTF-8?q?=D1=81=D0=B0=D0=B4=D0=BE=D1=87=D0=BD=D0=BE=D0=B9=20=D1=81=D1=82?= =?UTF-8?q?=D1=80=D0=B0=D0=BD=D0=B8=D1=86=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- project/templates/lilcity/links.html | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/project/templates/lilcity/links.html b/project/templates/lilcity/links.html index 4e94cf59..6df799a8 100644 --- a/project/templates/lilcity/links.html +++ b/project/templates/lilcity/links.html @@ -32,12 +32,15 @@ Бесплатный пробный урок + + Онлайн школа - - Месяц открытых дверей + + + Видеокурсы From 6a929267e6bc933a3881024f3b993fc29a345c99 Mon Sep 17 00:00:00 2001 From: gzbender Date: Thu, 22 Aug 2019 20:17:23 +0300 Subject: [PATCH 06/10] =?UTF-8?q?=D0=9E=D0=BF=D0=BB=D0=B0=D1=82=D0=B0=20?= =?UTF-8?q?=D0=B1=D0=BE=D0=BD=D1=83=D1=81=D0=B0=D0=BC=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/payment/views.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/apps/payment/views.py b/apps/payment/views.py index 34eb6bc2..e2c11d14 100644 --- a/apps/payment/views.py +++ b/apps/payment/views.py @@ -14,7 +14,7 @@ from django.http import HttpResponse, Http404 from django.shortcuts import redirect, get_object_or_404 from django.views.generic import View, TemplateView from django.views.decorators.csrf import csrf_exempt -from django.urls import reverse +from django.urls import reverse_lazy from django.utils.decorators import method_decorator from django.utils.timezone import now @@ -59,7 +59,7 @@ class SchoolBuySuccessView(TemplateView): @method_decorator(login_required, name='dispatch') class CourseBuyView(TemplateView): - template_name = 'payment/paymentwall_widget.html' + template_name = 'payment/pay.html' def get(self, request, pk=None, *args, **kwargs): use_bonuses = request.GET.get('use_bonuses') @@ -119,7 +119,6 @@ class CourseBuyView(TemplateView): @method_decorator(login_required, name='dispatch') class SchoolBuyView(TemplateView): - # template_name = 'payment/paymentwall_widget.html' template_name = 'payment/pay.html' def get(self, request, *args, **kwargs): @@ -156,7 +155,7 @@ class SchoolBuyView(TemplateView): school_payment.bonus = bonus school_payment.save() if school_payment.is_paid(): - return redirect('%s?duration=%s' % (reverse('payment-success'), duration)) + return redirect('%s?duration=%s' % (str(reverse_lazy('payment-success')), duration)) if payment_id and school_payment.bonus and not use_bonuses: bonus = school_payment.bonus school_payment.amount += school_payment.bonus @@ -178,8 +177,8 @@ class SchoolBuyView(TemplateView): 'evaluation': 1, 'demo': 1, 'test_mode': 1, - 'success_url': host + reverse('payment-success') + '?duration=%s' % duration, - 'failure_url': host + reverse('payment-error'), + 'success_url': host + str(reverse_lazy('payment-success')) + '?duration=%s' % duration, + 'failure_url': host + str(reverse_lazy('payment-error')), } ) if self.request.is_ajax(): @@ -193,7 +192,7 @@ class SchoolBuyView(TemplateView): @method_decorator(login_required, name='dispatch') class DrawingCampBuyView(TemplateView): - template_name = 'payment/paymentwall_widget.html' + template_name = 'payment/pay.html' def get(self, request, *args, **kwargs): host = urlsplit(self.request.META.get('HTTP_REFERER')) @@ -411,7 +410,7 @@ class GiftCertificatesView(TemplateView): @method_decorator(login_required, name='dispatch') class GiftCertificateBuyView(TemplateView): model = GiftCertificate - template_name = 'payment/paymentwall_widget.html' + template_name = 'payment/pay.html' def get(self, request, pk, *args, **kwargs): gift_certificate = get_object_or_404(GiftCertificate, pk=pk) From b9be5052ad14ccca293cb0ec55201277f09ff25f Mon Sep 17 00:00:00 2001 From: gzbender Date: Thu, 22 Aug 2019 20:54:01 +0300 Subject: [PATCH 07/10] =?UTF-8?q?=D0=9F=D0=BE=D0=BC=D0=B5=D0=BD=D1=8F?= =?UTF-8?q?=D1=82=D1=8C=20=D1=80=D0=B5=D1=84=D0=B5=D1=80=D0=B0=D0=BB=D1=8C?= =?UTF-8?q?=D0=BD=D1=83=D1=8E=20=D1=81=D1=81=D1=8B=D0=BB=D0=BA=D1=83,=20?= =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D1=82=D1=8C=20UTM=20=D0=BC?= =?UTF-8?q?=D0=B5=D1=82=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/user/models.py | 5 +++-- project/templates/blocks/footer.html | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/apps/user/models.py b/apps/user/models.py index d24edf15..efeda23d 100644 --- a/apps/user/models.py +++ b/apps/user/models.py @@ -114,8 +114,9 @@ class User(AbstractUser): @property def ref_url(self): - return 'https://%s%s?referrer=%s' % ( - settings.MAIN_HOST, reverse('index'), short_url.encode_url(self.id) + code = short_url.encode_url(self.id) + return 'https://%s%s?referrer=%s&utm_source=referral&utm_medium=referral&utm_content=%s&utm_campaign=ref_campaign' % ( + settings.MAIN_HOST, reverse('index'), code, code ) if self.id else '' def serialized(self): diff --git a/project/templates/blocks/footer.html b/project/templates/blocks/footer.html index 07edfa55..1ef452b3 100644 --- a/project/templates/blocks/footer.html +++ b/project/templates/blocks/footer.html @@ -21,8 +21,8 @@