Przeglądaj źródła

Bug-Fix for render_metadata

master
Dirk Alders 2 miesięcy temu
rodzic
commit
f9c202f2ca
2 zmienionych plików z 10 dodań i 6 usunięć
  1. 8
    4
      pages/__init__.py
  2. 2
    2
      pages/page.py

+ 8
- 4
pages/__init__.py Wyświetl plik

@@ -25,7 +25,11 @@ def get_search_query(request):
25 25
 def timestamp_to_datetime(request, tm):
26 26
     from users.models import get_userprofile
27 27
     #
28
-    up = get_userprofile(request.user)
29
-    tz = zoneinfo.ZoneInfo(up.timezone)
30
-    #
31
-    return datetime.fromtimestamp(tm, tz)
28
+    try:
29
+        up = get_userprofile(request.user)
30
+    except AttributeError:
31
+        return datetime.fromtimestamp(tm)
32
+    else:
33
+        tz = zoneinfo.ZoneInfo(up.timezone)
34
+        #
35
+        return datetime.fromtimestamp(tm, tz)

+ 2
- 2
pages/page.py Wyświetl plik

@@ -165,8 +165,8 @@ class creole_page(base_page):
165 165
             return ""
166 166
 
167 167
     def render_meta(self):
168
-        ctime = timestamp_to_datetime(self._meta_data.get(self._meta_data.KEY_CREATION_TIME)).strftime('%Y-%m-%d %H:%M')
169
-        mtime = timestamp_to_datetime(self._meta_data.get(self._meta_data.KEY_MODIFIED_TIME)).strftime('%Y-%m-%d %H:%M')
168
+        ctime = timestamp_to_datetime(self._request, self._meta_data.get(self._meta_data.KEY_CREATION_TIME)).strftime('%Y-%m-%d %H:%M')
169
+        mtime = timestamp_to_datetime(self._request, self._meta_data.get(self._meta_data.KEY_MODIFIED_TIME)).strftime('%Y-%m-%d %H:%M')
170 170
         user = self._meta_data.get(self._meta_data.KEY_MODIFIED_USER)
171 171
         #
172 172
         meta = f'|{_("Created")}:|{ctime}|\n'

Ładowanie…
Anuluj
Zapisz