From 5cdb9ad43bf83d5c0c51696276db48fba15c8542 Mon Sep 17 00:00:00 2001 From: Kumi Date: Mon, 1 Jul 2024 12:06:30 +0200 Subject: [PATCH] feat: add filter to convert month number to name Added a custom filter `month_name` to convert month numbers to their full names in templates. Updated the Transparency Report title to use this filter, enhancing readability and user experience. This change ensures that month names are displayed instead of numeric values, making the report titles clearer and more user-friendly. --- main.py | 8 ++++++++ templates/transparency.html | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index c061fb2..2155665 100644 --- a/main.py +++ b/main.py @@ -34,6 +34,14 @@ def icon(icon_name): env.filters["icon"] = icon +# Filter for rendering a month name from a number +def month_name(month_number): + return datetime.date(1900, int(month_number), 1).strftime("%B") + + +env.filters["month_name"] = month_name + + def render_template_to_file(template_name, output_name, **kwargs): try: template = env.get_template(template_name) diff --git a/templates/transparency.html b/templates/transparency.html index 59626c2..3a76ea5 100644 --- a/templates/transparency.html +++ b/templates/transparency.html @@ -14,7 +14,7 @@ {% for month, month_data in year_data.items() %}
-
Transparency Report for {{ month }}/{{ year }}
+
Transparency Report for {{ month|month_name }} {{ year }}
{{ month_data|safe }}