From 4312b61e3bbcbee7a8fbcae27d5164b56c6dc340 Mon Sep 17 00:00:00 2001 From: gzbender Date: Tue, 21 Aug 2018 00:49:35 +0500 Subject: [PATCH] LIL-622 --- apps/school/views.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/school/views.py b/apps/school/views.py index c2c916d1..9e426c3d 100644 --- a/apps/school/views.py +++ b/apps/school/views.py @@ -133,11 +133,15 @@ class SchoolView(TemplateView): school_schedule.current_live_lesson() ) + school_schedules = SchoolSchedule.objects.all() + try: + school_schedules = sorted(school_schedules, key=lambda ss: ss.current_live_lesson and ss.current_live_lesson.date) + except Exception: + pass school_schedules_dict = {ss.weekday: ss for ss in school_schedules} school_schedules_dict[0] = school_schedules_dict.get(7) all_schedules_purchased = [] if self.request.user.is_authenticated: - school_schedules = sorted(SchoolSchedule.objects.all(), key=lambda ss: ss.current_live_lesson.date) all_schedules_purchased = SchoolPayment.objects.filter( user=self.request.user, status__in=[ @@ -181,7 +185,6 @@ class SchoolView(TemplateView): joined_weekdays=Func(F('weekdays'), function='unnest',) ).values_list('joined_weekdays', flat=True).distinct() else: - school_schedules = SchoolSchedule.objects.all() school_payment_exists = False school_payment_exists_future = False school_purchased_future = False