changeset 1580:08342aca8c1e

pages: make `tz_data` always available as template data and exposed to scripts
author Goffi <goffi@goffi.org>
date Tue, 28 Nov 2023 17:52:09 +0100
parents 5db55d01ce05
children fe1995d0df09
files libervia/web/pages/calendar/page_meta.py libervia/web/server/pages.py
diffstat 2 files changed, 5 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/libervia/web/pages/calendar/page_meta.py	Wed Nov 22 16:31:36 2023 +0100
+++ b/libervia/web/pages/calendar/page_meta.py	Tue Nov 28 17:52:09 2023 +0100
@@ -35,7 +35,6 @@
         else:
             template_data["events"] = events
 
-    tz_name = template_data["tz_name"] = time.tzname[0]
     local_tz = tz.tzlocal()
     today_local = datetime.datetime.now(local_tz).date()
     calendar_start = template_data["calendar_start"] = datetime.datetime.combine(
@@ -48,5 +47,4 @@
         request,
         calendar_start=calendar_start,
         calendar_end=calendar_end,
-        tz_name=tz_name,
     )
--- a/libervia/web/server/pages.py	Wed Nov 22 16:31:36 2023 +0100
+++ b/libervia/web/server/pages.py	Tue Nov 28 17:52:09 2023 +0100
@@ -1406,7 +1406,9 @@
             request,
             cache_path=session_data.cache_dir,
             templates_root_url=str(self.vhost_root.get_front_url(theme)),
-            profile=session_data.profile)
+            profile=session_data.profile,
+            tz_name=template_data["tz_name"]
+        )
 
         uri = request.uri.decode()
         try:
@@ -1676,7 +1678,8 @@
                 # is used because the page may be cached, and the token then leaked
                 "csrf_token": "" if profile is None else session_data.csrf_token,
                 "session_uuid": "public" if profile is None else session_data.uuid,
-                "breadcrumbs": []
+                "breadcrumbs": [],
+                "tz_name": time.tzname[0]
             }
 
             # XXX: here is the code which need to be executed once