diff --git a/apps/school/templates/blocks/promo.html b/apps/school/templates/blocks/promo.html index 2bdd1282..72137dbb 100644 --- a/apps/school/templates/blocks/promo.html +++ b/apps/school/templates/blocks/promo.html @@ -2,7 +2,7 @@
- Lil City School — первая образовательная онлайн-платформа креативного мышления для детей
+ Lil School — первая образовательная онлайн-платформа креативного мышления для детей
смотреть урок diff --git a/apps/school/templates/summer/promo.html b/apps/school/templates/summer/promo.html index 24f2b286..7bdf1178 100644 --- a/apps/school/templates/summer/promo.html +++ b/apps/school/templates/summer/promo.html @@ -9,14 +9,21 @@
Получить доступ + class="main__btn btn" + href="#" + > + {% 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/school/views.py b/apps/school/views.py index b17bd1d2..ae9b64f0 100644 --- a/apps/school/views.py +++ b/apps/school/views.py @@ -198,11 +198,28 @@ class SummerSchoolView(TemplateView): date_end__gte=date_now ) school_payment_exists = school_payment.exists() + + school_payment_future = SchoolPayment.objects.filter( + user=self.request.user, + status__in=[ + Pingback.PINGBACK_TYPE_REGULAR, + Pingback.PINGBACK_TYPE_GOODWILL, + Pingback.PINGBACK_TYPE_RISK_REVIEWED_ACCEPTED, + ], + date_start__gte=date_now, + date_end__gte=date_now + ) + + school_payment_exists_future = school_payment_future.exists() + school_purchased_future = school_payment_future.last() + school_schedules_purchased = school_payment.annotate( joined_weekdays=Func(F('weekdays'), function='unnest',) ).values_list('joined_weekdays', flat=True).distinct() else: school_payment_exists = False + school_payment_exists_future = False + school_purchased_future = False school_schedules_purchased = [] if school_payment_exists and is_previous: live_lessons = LiveLesson.objects.filter( @@ -221,9 +238,11 @@ class SummerSchoolView(TemplateView): 'is_previous': is_previous, 'course_items': Course.objects.filter(status=Course.PUBLISHED)[:6], 'is_purchased': school_payment_exists, + 'is_purchased_future': school_payment_exists_future, 'min_school_price': SchoolSchedule.objects.aggregate(Min('month_price'))['month_price__min'], 'school_schedules': SchoolSchedule.objects.all(), 'school_schedules_purchased': school_schedules_purchased, + 'school_purchased_future': school_purchased_future, 'subscription_ends': school_payment.filter(add_days=False).first().date_end if school_payment_exists else None, }) return context diff --git a/apps/user/templates/user/profile.html b/apps/user/templates/user/profile.html index 7a10411d..16eec912 100644 --- a/apps/user/templates/user/profile.html +++ b/apps/user/templates/user/profile.html @@ -79,25 +79,33 @@
- {% if is_purchased %} - {% include "blocks/schedule_purchased.html" %} + {% if is_purchased_future %} +
+
+
Ваша подписка начинается {{school_purchased_future.date_start}}
+
+
{% else %} -
-
-
Вы не подписаны на школу!
-
- Купить подписку + {% if is_purchased %} + {% include "blocks/schedule_purchased.html" %} + {% else %} +
+
+
Вы не подписаны на школу!
+
-
+ {% endif %} {% endif %}
diff --git a/apps/user/views.py b/apps/user/views.py index 4584950a..4f9019e9 100644 --- a/apps/user/views.py +++ b/apps/user/views.py @@ -96,6 +96,15 @@ class UserView(DetailView): ).all() context['all_school_schedules'] = SchoolSchedule.objects.all() + school_payment_future = SchoolPayment.objects.filter( + user=self.request.user, + date_start__gte=now(), + date_end__gte=now() + ) + + context['is_purchased_future'] = school_payment_future.exists() + context['school_purchased_future'] = school_payment_future.last() + return context diff --git a/project/templates/blocks/promo.html b/project/templates/blocks/promo.html index 9e2f929f..9c37b96a 100644 --- a/project/templates/blocks/promo.html +++ b/project/templates/blocks/promo.html @@ -15,27 +15,22 @@ Присоединяйтесь в Рисовальный лагерь
- {% if is_purchased %} ваша подписка истекает {{ subscription_ends_humanize }}
перейти к оплате
- {% else %} - Получить доступ - {% endif %} + class="main__btn btn" + href="#" + > + {% 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/project/views.py b/project/views.py index 1777eea3..61e62c90 100644 --- a/project/views.py +++ b/project/views.py @@ -44,8 +44,20 @@ class IndexView(TemplateView): school_payment_exists = school_payment.exists() school_schedules_purchased = school_payment.values_list('weekdays', flat=True) school_schedules_purchased = school_schedules_purchased[0] if school_schedules_purchased else [] + + school_payment_future = SchoolPayment.objects.filter( + user=self.request.user, + date_start__gte=date_now, + date_end__gte=date_now + ) + + school_payment_exists_future = school_payment_future.exists() + school_purchased_future = school_payment_future.last() + else: school_payment_exists = False + school_payment_exists_future = False + school_purchased_future = False school_schedules_purchased = [] context.update({ @@ -58,6 +70,10 @@ class IndexView(TemplateView): 'teachers': User.objects.filter(role=User.TEACHER_ROLE, show_in_mainpage=True), 'subscription_ends': school_payment.filter(add_days=False).first().date_end if school_payment_exists else None, 'subscription_ends_humanize': school_payment.filter(add_days=False).first().date_end_humanize if school_payment_exists else None, + + 'school_purchased_future': school_purchased_future, + 'is_purchased_future': school_payment_exists_future, + }) return context