|
|
|
|
@ -1,3 +1,5 @@ |
|
|
|
|
from time import time |
|
|
|
|
import decimal |
|
|
|
|
from datetime import datetime, timedelta |
|
|
|
|
|
|
|
|
|
from django.db.models import Min |
|
|
|
|
@ -31,28 +33,14 @@ class IndexView(TemplateView): |
|
|
|
|
school_schedule = None |
|
|
|
|
else: |
|
|
|
|
end_at = datetime.combine(now_time.today(), school_schedule.start_at) |
|
|
|
|
online = ( |
|
|
|
|
school_schedule.start_at <= now_time.time() and |
|
|
|
|
(end_at + timedelta(hours=2)).time() >= now_time.time() and |
|
|
|
|
school_schedule.current_live_lesson() |
|
|
|
|
) |
|
|
|
|
online_coming_soon = ( |
|
|
|
|
school_schedule.start_at > now_time.time() and |
|
|
|
|
( |
|
|
|
|
datetime.combine(datetime.today(), school_schedule.start_at) - timedelta(hours=12) |
|
|
|
|
).time() <= now_time.time() and |
|
|
|
|
school_schedule.current_live_lesson() |
|
|
|
|
) |
|
|
|
|
online = school_schedule.is_online() |
|
|
|
|
online_coming_soon = school_schedule.online_coming_soon() |
|
|
|
|
|
|
|
|
|
date_now = now_time.date() |
|
|
|
|
if self.request.user.is_authenticated: |
|
|
|
|
school_payment = SchoolPayment.objects.filter( |
|
|
|
|
user=self.request.user, |
|
|
|
|
date_start__lte=date_now, |
|
|
|
|
date_end__gte=date_now |
|
|
|
|
) |
|
|
|
|
school_payment_exists = school_payment.exists() |
|
|
|
|
school_schedules_purchased = school_payment.values_list('weekdays', flat=True) |
|
|
|
|
schoolpayment_queryset = self.request.user.school_payments() |
|
|
|
|
school_payment_exists = schoolpayment_queryset.exists() |
|
|
|
|
school_schedules_purchased = schoolpayment_queryset.values_list('weekdays', flat=True) |
|
|
|
|
school_schedules_purchased = school_schedules_purchased[0] if school_schedules_purchased else [] |
|
|
|
|
|
|
|
|
|
school_payment_future = SchoolPayment.objects.filter( |
|
|
|
|
@ -69,7 +57,6 @@ class IndexView(TemplateView): |
|
|
|
|
school_payment_exists_future = False |
|
|
|
|
school_purchased_future = False |
|
|
|
|
school_schedules_purchased = [] |
|
|
|
|
|
|
|
|
|
context.update({ |
|
|
|
|
'online': online, |
|
|
|
|
'online_coming_soon': online_coming_soon, |
|
|
|
|
@ -80,8 +67,8 @@ class IndexView(TemplateView): |
|
|
|
|
'school_schedules': SchoolSchedule.objects.all(), |
|
|
|
|
'school_schedules_purchased': school_schedules_purchased, |
|
|
|
|
'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, |
|
|
|
|
'subscription_ends': schoolpayment_queryset.filter(add_days=False).first().date_end if school_payment_exists else None, |
|
|
|
|
'subscription_ends_humanize': schoolpayment_queryset.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, |
|
|
|
|
|