|
|
|
|
@ -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 |
|
|
|
|
|
|
|
|
|
|