From 55e14d42838a826e44c2e03bb8f06a36c2986a12 Mon Sep 17 00:00:00 2001 From: gzbender Date: Mon, 1 Oct 2018 14:45:18 +0500 Subject: [PATCH] lil-583 --- apps/school/views.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/apps/school/views.py b/apps/school/views.py index 3b1c3b70..7158353f 100644 --- a/apps/school/views.py +++ b/apps/school/views.py @@ -135,6 +135,7 @@ class SchoolView(TemplateView): school_schedules_dict[0] = school_schedules_dict.get(7) live_lessons = None live_lessons_exists = False + subscription_ends = None if self.request.user.is_authenticated: school_payment = SchoolPayment.objects.filter( user=self.request.user, @@ -149,7 +150,13 @@ class SchoolView(TemplateView): status__in=SchoolPayment.PW_PAID_STATUSES, date_start__gt=date_now, date_end__gt=date_now - ).exists() + ) + + if school_purchased_future.exists(): + subscription_ends = school_purchased_future.filter(add_days=False).latest( + 'date_end').date_end + elif school_payment_exists: + subscription_ends = school_payment.filter(add_days=False).latest('date_end').date_end school_schedules_purchased = school_payment.annotate( joined_weekdays=Func(F('weekdays'), function='unnest',) @@ -184,7 +191,7 @@ class SchoolView(TemplateView): ll.school_schedule = school_schedules_dict.get(ll.date.isoweekday()) live_lessons_exists = live_lessons.exists() live_lessons = live_lessons or None - subscription_ends = school_payment.filter(add_days=False).latest('date_end').date_end if school_payment_exists else None + context.update({ 'online': online, 'live_lessons': live_lessons,