Add subscription_ends & is_purchased to SchoolView context

remotes/origin/hasaccess
Ivlev Denis 8 years ago
parent f6fd01d601
commit d29858ae94
  1. 5
      apps/school/views.py

@ -75,7 +75,12 @@ class SchoolView(TemplateView):
def get_context_data(self):
context = super().get_context_data()
date_now = now().date()
school_payment = SchoolPayment.objects.filter(date_start__lte=date_now, date_end__gte=date_now)
school_payment_exists = school_payment.exists()
context.update({
'subscription_ends': school_payment.first().date_end if school_payment_exists else None,
'is_purchased': school_payment_exists,
'school_schedules': SchoolSchedule.objects.all(),
'min_school_price': SchoolSchedule.objects.aggregate(Min('month_price'))['month_price__min'],
})

Loading…
Cancel
Save