diff --git a/apps/payment/templates/payment/pay.html b/apps/payment/templates/payment/pay.html new file mode 100644 index 00000000..ec26e9ca --- /dev/null +++ b/apps/payment/templates/payment/pay.html @@ -0,0 +1,29 @@ +{% extends "templates/lilcity/index.html" %} +{% load static %} +{% load rupluralize from plural %} + +{% block content %} +
+
+ {% 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/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..e2c11d14 100644 --- a/apps/payment/views.py +++ b/apps/payment/views.py @@ -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,7 @@ 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): host = urlsplit(self.request.META.get('HTTP_REFERER')) @@ -128,30 +128,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')) + 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 + school_payment.bonus = None + bonus.delete() product = Product( f'school_{school_payment.id}', school_payment.amount, @@ -172,12 +181,18 @@ class SchoolBuyView(TemplateView): 'failure_url': host + str(reverse_lazy('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') 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')) @@ -395,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) diff --git a/apps/school/templates/blocks/schedule_item.html b/apps/school/templates/blocks/schedule_item.html index 66e80182..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 %}
@@ -20,11 +17,13 @@ {% 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 %} + {% if not is_purchased and school_schedule.trial_lesson %} Пробный урок {% endif %}
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 @@
- {% if not is_purchased and not is_purchased_future %}Купить доступ от {{ min_school_price }} руб./месяц{% endif %} + {% if not is_purchased and not is_purchased_future %}Узнать стоимость{% endif %} {% if is_purchased_future and not is_purchased %}ваша подписка начинается {{school_purchased_future.date_start}}{% endif %} {% if is_purchased %}ваша подписка истекает {{ subscription_ends_humanize }}
перейти к оплате{% endif %}
diff --git a/apps/user/models.py b/apps/user/models.py index d24edf15..7a774998 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): @@ -155,7 +156,7 @@ class User(AbstractUser): last_bonus = self.bonuses.filter( Q(payment__isnull=False, payment__status__in=Payment.PW_PAID_STATUSES) | Q(is_service=True), ).order_by('-created_at').first() - return bool(last_bonus) and not last_bonus.notified_at + return bool(last_bonus) and last_bonus.amount > 0 and not last_bonus.notified_at @property def paid_one_more(self): diff --git a/docker/Dockerfile b/docker/Dockerfile index acaa74c8..d8ad9cf1 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -9,7 +9,7 @@ RUN yarn build FROM python:3.6 ENV PYTHONUNBUFFERED 1 -RUN apt-get update && apt-get install -y nginx supervisor +RUN apt-get update && apt-get install -y nginx supervisor sudo RUN pip3 install --no-cache-dir --upgrade pip uwsgi==2.0.17 WORKDIR /app/ ADD requirements.txt /app/ diff --git a/docker/entrypoint_app.sh b/docker/entrypoint_app.sh index a346f89c..1b6da756 100755 --- a/docker/entrypoint_app.sh +++ b/docker/entrypoint_app.sh @@ -1,6 +1,6 @@ #!/bin/sh cd /app chown www-data:www-data /app/media -python manage.py migrate +sudo -E -u www-data python manage.py migrate #python manage.py loaddata /app/apps/*/fixtures/*.json python2.7 /usr/bin/supervisord -n 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 @@
@@ -45,11 +45,11 @@ -
- - БЕСПЛАТНЫЕ УРОКИ - -
+ + + + +
ВИДЕО-КУРСЫ
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 @@ Бесплатный пробный урок + + Онлайн школа - - Месяц открытых дверей + + + Видеокурсы 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 2b362379..63c0801b 100755 --- a/web/src/sass/_common.sass +++ b/web/src/sass/_common.sass @@ -1018,6 +1018,9 @@ a[name] border-radius: 10px box-shadow: 0 11px 20px 0 rgba(0, 0, 0, 0.1) + & .btn:before + border-radius: 10px + &_main padding: 80px 0 +m @@ -4362,9 +4365,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 @@ -5240,6 +5241,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/*.*'),