From 7cea6dff2ec8773528706b099fb7d3acd6b9b191 Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Thu, 19 Mar 2020 16:46:18 +0000 Subject: [PATCH 1/1] Allow counters in banner text. --- src/annoy/models.py | 4 ++++ src/annoy/templates/annoy/banner.html | 2 +- src/club/templatetags/club.py | 4 ++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/annoy/models.py b/src/annoy/models.py index 9ed724c0e..488fa87a8 100644 --- a/src/annoy/models.py +++ b/src/annoy/models.py @@ -1,6 +1,7 @@ from django.apps import apps from django.conf import settings from django.db import models +from django.template import Context, Template from django.utils.translation import ugettext_lazy as _ from django.utils.timezone import now from .places import PLACES, PLACE_CHOICES @@ -34,6 +35,9 @@ class Banner(models.Model): def __str__(self): return self.text + def get_text(self): + return Template(self.text).render(Context()) + @classmethod def choice(cls, place, request): Membership = apps.get_model('club', 'Membership') diff --git a/src/annoy/templates/annoy/banner.html b/src/annoy/templates/annoy/banner.html index 012be118e..9d001683c 100644 --- a/src/annoy/templates/annoy/banner.html +++ b/src/annoy/templates/annoy/banner.html @@ -17,7 +17,7 @@ {% endif %}
- {{ banner.text|safe|linebreaks }} + {{ banner.get_text|safe|linebreaks }}
{% if banner.action_label %} diff --git a/src/club/templatetags/club.py b/src/club/templatetags/club.py index b0ce86817..42913fe93 100644 --- a/src/club/templatetags/club.py +++ b/src/club/templatetags/club.py @@ -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( -- 2.20.1