Update profile school qs

remotes/origin/hasaccess
Ivlev Denis 8 years ago
parent 4cc52836e9
commit e3396acbd0
  1. 12
      apps/user/views.py

@ -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
@ -72,12 +73,15 @@ class UserView(DetailView):
Pingback.PINGBACK_TYPE_GOODWILL,
Pingback.PINGBACK_TYPE_RISK_REVIEWED_ACCEPTED,
],
).last()
)
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 and school_payment.date_end:
context['school_days_left'] = (school_payment.date_end - now().date()).days
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_payment.weekdays if school_payment else [],
weekday__in=school_schedules_purchased if school_payment.exists() else [],
)
return context

Loading…
Cancel
Save