X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/56c5bac0c6b5fc622a0b274861a98b9dca00259e..HEAD:/src/club/templatetags/club.py diff --git a/src/club/templatetags/club.py b/src/club/templatetags/club.py index b0ce86817..79dc14478 100644 --- a/src/club/templatetags/club.py +++ b/src/club/templatetags/club.py @@ -1,5 +1,5 @@ -# This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later. -# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. +# This file is part of Wolne Lektury, licensed under GNU Affero GPLv3 or later. +# Copyright © Fundacja Wolne Lektury. See NOTICE for more information. # from datetime import timedelta from django.db.models import Sum @@ -17,6 +17,10 @@ def active_schedule(user): return get_active_schedule(user) +@register.simple_tag +def club_count_recurring(): + return Schedule.objects.exclude(monthly=False, yearly=False).filter(expires_at__gt=now()).count() + @register.simple_tag def club_active_monthly_count(): return Schedule.objects.filter( @@ -62,3 +66,20 @@ def club_active_30day_sum(): yearly=False, monthly=False, payed_at__gte=now() - timedelta(days=30) ).aggregate(s=Sum('amount'))['s'] or 0 + + +@register.simple_tag +def club_monthly_since(start): + return Schedule.objects.filter( + monthly=True, payed_at__gte=start).count() + + +@register.simple_tag +def club_monthly_missing_since(start, target): + return target - Schedule.objects.filter( + monthly=True, payed_at__gte=start).count() + + +@register.simple_tag(takes_context=True) +def invite_payment(context, payment_method, schedule): + return payment_method.invite_widget(schedule, context['request'])