X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/8952b9530d943655e552ea660c47e850123c5105..1a6ad5b9b48a5efa90410fd324c256f59f57e08f:/src/club/templatetags/club.py diff --git a/src/club/templatetags/club.py b/src/club/templatetags/club.py index 65dcd6847..7e8bc038c 100644 --- a/src/club/templatetags/club.py +++ b/src/club/templatetags/club.py @@ -1,8 +1,11 @@ # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later. # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. # +from django.db.models import Sum from django import template +from django.utils.timezone import now from ..helpers import get_active_schedule +from ..models import Schedule register = template.Library() @@ -11,3 +14,13 @@ register = template.Library() @register.filter def active_schedule(user): return get_active_schedule(user) + + +@register.simple_tag +def club_active_monthly_count(): + return Schedule.objects.filter(expires_at__gt=now(), monthly=True, is_cancelled=False).count() + +@register.simple_tag +def club_active_monthly_sum(): + return Schedule.objects.filter(expires_at__gt=now(), monthly=True, is_cancelled=False).aggregate(s=Sum('amount'))['s'] +