diff --git a/apps/course/templates/course/course.html b/apps/course/templates/course/course.html index 20266fe1..69f6e5df 100644 --- a/apps/course/templates/course/course.html +++ b/apps/course/templates/course/course.html @@ -29,17 +29,15 @@ Редактировать {% endif %} {% if course.author != request.user and not paid and course.price %} - {% if pending %}ОЖИДАЕТСЯ ПОДТВЕРЖДЕНИЕ ОПЛАТЫ{% else %}КУПИТЬ КУРС{% endif %} {% endif %} @@ -160,12 +158,14 @@ >УРОКИ {% else %} - УРОКИ {% if not paid and course.price %} @@ -324,16 +324,15 @@ {% endif %} {% if course.author != request.user and not paid and course.price %} - {% if pending %}ОЖИДАЕТСЯ ПОДТВЕРЖДЕНИЕ ОПЛАТЫ{% else %}КУПИТЬ КУРС{% endif %} {% endif %} diff --git a/apps/school/templates/blocks/schedule_purchased.html b/apps/school/templates/blocks/schedule_purchased.html index 5d1a5827..eb7cc8e2 100644 --- a/apps/school/templates/blocks/schedule_purchased.html +++ b/apps/school/templates/blocks/schedule_purchased.html @@ -6,9 +6,11 @@
{% if is_purchased %} -
Подписка истекает - {{ subscription_ends }} -
+ {% if not school_purchased_future %} +
Подписка истекает + {{ subscription_ends }} +
+ {% endif %} {% else %}
Подписка истекла diff --git a/apps/school/views.py b/apps/school/views.py index e86a309a..3403d453 100644 --- a/apps/school/views.py +++ b/apps/school/views.py @@ -138,21 +138,26 @@ class SchoolView(TemplateView): if self.request.user.is_authenticated: school_payment = SchoolPayment.objects.filter( user=self.request.user, - status__in=[ - Pingback.PINGBACK_TYPE_REGULAR, - Pingback.PINGBACK_TYPE_GOODWILL, - Pingback.PINGBACK_TYPE_RISK_REVIEWED_ACCEPTED, - ], + status__in=SchoolPayment.PW_PAID_STATUSES, + date_start__lte=date_now, date_end__gte=date_now ) school_payment_exists = school_payment.exists() + school_purchased_future = SchoolPayment.objects.filter( + user=self.request.user, + status__in=SchoolPayment.PW_PAID_STATUSES, + date_start__gt=date_now, + date_end__gt=date_now + ).exists() + 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_schedules_purchased = [] + school_purchased_future = False if is_previous: prev_range = [yesterday - timedelta(days=7), yesterday] live_lessons = [] @@ -192,10 +197,11 @@ class SchoolView(TemplateView): 'school_schedules_sorted': school_schedules_sorted, 'school_schedules': school_schedules, 'school_schedules_purchased': school_schedules_purchased, - 'school_purchased_future': False, - 'subscription_ends': subscription_ends, + 'school_purchased_future': school_purchased_future, + 'subscription_ends': subscription_ends if not school_purchased_future else None, 'prolong_date_start': subscription_ends + timedelta(days=1) if subscription_ends else None, - 'allow_prolong': subscription_ends - date_now <= timedelta(days=7) if subscription_ends else False, + 'allow_prolong': subscription_ends - date_now <= timedelta(days=7) + if not school_purchased_future and subscription_ends else False, }) return context diff --git a/project/templates/blocks/popup_course_buy.html b/project/templates/blocks/popup_course_buy.html index 1ce320ca..0498564d 100644 --- a/project/templates/blocks/popup_course_buy.html +++ b/project/templates/blocks/popup_course_buy.html @@ -9,12 +9,17 @@