1 # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
2 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
4 from django.db.models import Sum
5 from django import template
6 from django.utils.timezone import now
7 from ..helpers import get_active_schedule
8 from ..models import Schedule
11 register = template.Library()
15 def active_schedule(user):
16 return get_active_schedule(user)
20 def club_active_monthly_count():
21 return Schedule.objects.filter(expires_at__gt=now(), monthly=True, is_cancelled=False).count()
24 def club_active_monthly_sum():
25 return Schedule.objects.filter(expires_at__gt=now(), monthly=True, is_cancelled=False).aggregate(s=Sum('amount'))['s']