|
|
|
|
@ -17,6 +17,7 @@ from django.contrib.auth import get_user_model |
|
|
|
|
from django.contrib.auth.decorators import login_required, permission_required |
|
|
|
|
from django.contrib.auth.hashers import check_password, make_password |
|
|
|
|
from django.http import Http404 |
|
|
|
|
from django.db.models import F, Func |
|
|
|
|
from django.urls import reverse_lazy |
|
|
|
|
from django.utils.decorators import method_decorator |
|
|
|
|
from django.utils.timezone import now |
|
|
|
|
@ -63,6 +64,26 @@ class UserView(DetailView): |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
).distinct() |
|
|
|
|
school_payment = SchoolPayment.objects.filter( |
|
|
|
|
user=self.object, |
|
|
|
|
date_start__lte=now(), |
|
|
|
|
date_end__gt=now(), |
|
|
|
|
status__in=[ |
|
|
|
|
Pingback.PINGBACK_TYPE_REGULAR, |
|
|
|
|
Pingback.PINGBACK_TYPE_GOODWILL, |
|
|
|
|
Pingback.PINGBACK_TYPE_RISK_REVIEWED_ACCEPTED, |
|
|
|
|
], |
|
|
|
|
) |
|
|
|
|
school_schedules_purchased = school_payment.annotate( |
|
|
|
|
joined_weekdays=Func(F('weekdays'), function='unnest',) |
|
|
|
|
).values_list('joined_weekdays', flat=True).distinct() |
|
|
|
|
context['school_payment'] = school_payment |
|
|
|
|
if school_payment.exists() and school_payment.last().date_end: |
|
|
|
|
context['school_days_left'] = (school_payment.last().date_end - now().date()).days |
|
|
|
|
context['school_schedules'] = SchoolSchedule.objects.filter( |
|
|
|
|
weekday__in=school_schedules_purchased if school_payment.exists() else [], |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
return context |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|