aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Schadt <kingdread@gmx.de>2024-11-16 19:27:30 +0100
committerDaniel Schadt <kingdread@gmx.de>2024-11-16 19:27:30 +0100
commitb462965d89d3a942dddf9c49bfa79283a95ec3a5 (patch)
tree57c4dbcfc10ec61ea5d7250f4e381ae9a0208d1d
parenta88c715130f8a6ec3fb16ac9e694d447872aee1b (diff)
downloadfietsboek-b462965d89d3a942dddf9c49bfa79283a95ec3a5.tar.gz
fietsboek-b462965d89d3a942dddf9c49bfa79283a95ec3a5.tar.bz2
fietsboek-b462965d89d3a942dddf9c49bfa79283a95ec3a5.zip
add weekday names to calendar
-rw-r--r--fietsboek/templates/profile.jinja27
-rw-r--r--fietsboek/util.py14
-rw-r--r--fietsboek/views/profile.py2
3 files changed, 23 insertions, 0 deletions
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 @@
</div>
<table class="profile-calendar">
+ <thead>
+ <tr>
+ {% for day in range(7) %}
+ <td>{{ day_name(request, day) }}</td>
+ {% endfor %}
+ </tr>
+ </thead>
{% for row in calendar_rows %}
<tr>
{% 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