From b462965d89d3a942dddf9c49bfa79283a95ec3a5 Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Sat, 16 Nov 2024 19:27:30 +0100 Subject: add weekday names to calendar --- fietsboek/templates/profile.jinja2 | 7 +++++++ fietsboek/util.py | 14 ++++++++++++++ fietsboek/views/profile.py | 2 ++ 3 files changed, 23 insertions(+) diff --git a/fietsboek/templates/profile.jinja2 b/fietsboek/templates/profile.jinja2 index fb35920..ae61671 100644 --- a/fietsboek/templates/profile.jinja2 +++ b/fietsboek/templates/profile.jinja2 @@ -164,6 +164,13 @@ + + + {% for day in range(7) %} + + {% endfor %} + + {% for row in calendar_rows %} {% for cell in row %} diff --git a/fietsboek/util.py b/fietsboek/util.py index dcb9ab8..1d29600 100644 --- a/fietsboek/util.py +++ b/fietsboek/util.py @@ -244,6 +244,20 @@ def month_name(request: Request, month: int) -> str: return locale.months["stand-alone"]["wide"][month] +def day_name(request: Request, day: int) -> str: + """Returns the localized name for the day with the given number. + + 0 is Monday, 6 is Sunday. + + :param request: The pyramid request. + :param month: Number of the day, 0 = Monday, 6 = Sunday. + :return: The localized day name. + """ + assert 0 <= day <= 6 + locale = babel.Locale.parse(request.localizer.locale_name) + return locale.days["stand-alone"]["wide"][day] + + def random_link_secret(nbytes: int = 20) -> str: """Safely generates a secret suitable for the link share. diff --git a/fietsboek/views/profile.py b/fietsboek/views/profile.py index 0f96a50..ae5c34e 100644 --- a/fietsboek/views/profile.py +++ b/fietsboek/views/profile.py @@ -217,6 +217,7 @@ def profile(request: Request) -> dict: ) data["calendar_month"] = today data["calendar_prev"], data["calendar_next"] = prev_next_month(today) + data["day_name"] = util.day_name return data @@ -244,6 +245,7 @@ def user_calendar_ym(request: Request) -> dict: data["calendar_month"] = date data["calendar_prev"], data["calendar_next"] = prev_next_month(date) data["tab_focus"] = "calendar" + data["day_name"] = util.day_name return data -- cgit v1.2.3
{{ day_name(request, day) }}