|
|
|
@ -31,13 +31,15 @@ class IndexView(TemplateView): |
|
|
|
|
|
|
|
|
|
|
|
now_time = now() |
|
|
|
now_time = now() |
|
|
|
try: |
|
|
|
try: |
|
|
|
school_schedule = SchoolSchedule.objects.get(weekday=now_time.isoweekday(), is_camp=True) |
|
|
|
school_schedule = SchoolSchedule.objects.get( |
|
|
|
|
|
|
|
weekday=now_time.isoweekday(), is_camp=True) |
|
|
|
except SchoolSchedule.DoesNotExist: |
|
|
|
except SchoolSchedule.DoesNotExist: |
|
|
|
online = False |
|
|
|
online = False |
|
|
|
online_coming_soon = False |
|
|
|
online_coming_soon = False |
|
|
|
school_schedule = None |
|
|
|
school_schedule = None |
|
|
|
else: |
|
|
|
else: |
|
|
|
end_at = datetime.combine(now_time.today(), school_schedule.start_at) |
|
|
|
end_at = datetime.combine( |
|
|
|
|
|
|
|
now_time.today(), school_schedule.start_at) |
|
|
|
online = ( |
|
|
|
online = ( |
|
|
|
school_schedule.start_at <= now_time.time() and |
|
|
|
school_schedule.start_at <= now_time.time() and |
|
|
|
(end_at + timedelta(hours=1)).time() >= now_time.time() and |
|
|
|
(end_at + timedelta(hours=1)).time() >= now_time.time() and |
|
|
|
@ -45,7 +47,8 @@ class IndexView(TemplateView): |
|
|
|
) |
|
|
|
) |
|
|
|
online_coming_soon = ( |
|
|
|
online_coming_soon = ( |
|
|
|
school_schedule.start_at > now_time.time() and |
|
|
|
school_schedule.start_at > now_time.time() and |
|
|
|
datetime.combine(datetime.today(), school_schedule.start_at) - timedelta(hours=12) |
|
|
|
datetime.combine( |
|
|
|
|
|
|
|
datetime.today(), school_schedule.start_at) - timedelta(hours=12) |
|
|
|
<= datetime.combine(datetime.today(), now_time.time()) and |
|
|
|
<= datetime.combine(datetime.today(), now_time.time()) and |
|
|
|
school_schedule.current_camp_lesson |
|
|
|
school_schedule.current_camp_lesson |
|
|
|
) |
|
|
|
) |
|
|
|
@ -91,14 +94,17 @@ class IndexView(TemplateView): |
|
|
|
|
|
|
|
|
|
|
|
if user_gift_certificate: |
|
|
|
if user_gift_certificate: |
|
|
|
try: |
|
|
|
try: |
|
|
|
user_gift_certificate = short_url.decode_url(user_gift_certificate) |
|
|
|
user_gift_certificate = short_url.decode_url( |
|
|
|
user_gift_certificate = UserGiftCertificate.objects.get(pk=user_gift_certificate, bonuses_sent__isnull=True) |
|
|
|
user_gift_certificate) |
|
|
|
|
|
|
|
user_gift_certificate = UserGiftCertificate.objects.get( |
|
|
|
|
|
|
|
pk=user_gift_certificate, bonuses_sent__isnull=True) |
|
|
|
except: |
|
|
|
except: |
|
|
|
user_gift_certificate = None |
|
|
|
user_gift_certificate = None |
|
|
|
|
|
|
|
|
|
|
|
review_images = list(map(str, range(1, 107))) |
|
|
|
review_images = list(map(str, range(1, 107))) |
|
|
|
shuffle(review_images) |
|
|
|
shuffle(review_images) |
|
|
|
teachers = User.objects.filter(role=User.TEACHER_ROLE, show_in_mainpage=True) |
|
|
|
teachers = User.objects.filter( |
|
|
|
|
|
|
|
role=User.TEACHER_ROLE, show_in_mainpage=True) |
|
|
|
if teachers.count() % 2 == 0: |
|
|
|
if teachers.count() % 2 == 0: |
|
|
|
teachers = teachers[:teachers.count() - 1] |
|
|
|
teachers = teachers[:teachers.count() - 1] |
|
|
|
|
|
|
|
|
|
|
|
@ -128,6 +134,7 @@ class IndexView(TemplateView): |
|
|
|
'is_purchased_future': False, |
|
|
|
'is_purchased_future': False, |
|
|
|
|
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
return context |
|
|
|
return context |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -136,7 +143,8 @@ class SchoolSchedulesView(TemplateView): |
|
|
|
|
|
|
|
|
|
|
|
def get_context_data(self): |
|
|
|
def get_context_data(self): |
|
|
|
context = super().get_context_data() |
|
|
|
context = super().get_context_data() |
|
|
|
context['school_schedules'] = SchoolSchedule.objects.filter(is_camp=True) |
|
|
|
context['school_schedules'] = SchoolSchedule.objects.filter( |
|
|
|
|
|
|
|
is_camp=True) |
|
|
|
return context |
|
|
|
return context |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -163,12 +171,13 @@ class PackagesView(TemplateView): |
|
|
|
context['last_school_payment'] = last_school_payment |
|
|
|
context['last_school_payment'] = last_school_payment |
|
|
|
if last_school_payment: |
|
|
|
if last_school_payment: |
|
|
|
next_month = (last_school_payment.date_end + timedelta(1)).month |
|
|
|
next_month = (last_school_payment.date_end + timedelta(1)).month |
|
|
|
context['next_buy_date'] = last_school_payment.date_end + timedelta(1) |
|
|
|
context['next_buy_date'] = last_school_payment.date_end + \ |
|
|
|
|
|
|
|
timedelta(1) |
|
|
|
context['school_months_left'] = (school_end.month - next_month |
|
|
|
context['school_months_left'] = (school_end.month - next_month |
|
|
|
if next_month <= school_end.month |
|
|
|
if next_month <= school_end.month |
|
|
|
else (school_end.month + 13) - next_month) |
|
|
|
else (school_end.month + 13) - next_month) |
|
|
|
else: |
|
|
|
else: |
|
|
|
context['school_months_left'] = (school_end.month - today.month |
|
|
|
context['school_months_left'] = (school_end.month - today.month |
|
|
|
if today.month <= school_end.month |
|
|
|
if today.month <= school_end.month |
|
|
|
else (school_end.month + 13) - today.month) |
|
|
|
else (school_end.month + 13) - today.month) |
|
|
|
return context |
|
|
|
return context |
|
|
|
|