|
|
|
|
@ -77,12 +77,18 @@ class UserView(DetailView): |
|
|
|
|
school_schedules_purchased = school_payment.annotate( |
|
|
|
|
joined_weekdays=Func(F('weekdays'), function='unnest',) |
|
|
|
|
).values_list('joined_weekdays', flat=True).distinct() |
|
|
|
|
context['school_schedules_purchased'] = school_schedules_purchased |
|
|
|
|
context['school_payment'] = school_payment |
|
|
|
|
context['is_purchased'] = school_payment.exists() |
|
|
|
|
context['profile'] = True |
|
|
|
|
if school_payment.exists() and school_payment.last().date_end: |
|
|
|
|
context['school_days_left'] = (school_payment.last().date_end - now().date()).days |
|
|
|
|
context['subscription_ends'] = school_payment.last().date_end |
|
|
|
|
context['school_schedules'] = SchoolSchedule.objects.filter( |
|
|
|
|
weekday__in=school_schedules_purchased if school_payment.exists() else [], |
|
|
|
|
) |
|
|
|
|
).annotate( |
|
|
|
|
calk=F('weekday') - now().isoweekday(), |
|
|
|
|
weight=(7 + F('calk') % 7) % 7, |
|
|
|
|
).order_by('weight') |
|
|
|
|
|
|
|
|
|
return context |
|
|
|
|
|
|
|
|
|
|