avoid missing site variable

This commit is contained in:
rimu 2024-04-10 08:48:31 +12:00
parent 2d6e175092
commit 9d1f1a9f14

View file

@ -796,7 +796,11 @@ def current_theme():
if current_user.theme is not None and current_user.theme != '':
return current_user.theme
else:
return g.site.default_theme if g.site.default_theme is not None else ''
if hasattr(g, 'site'):
site = g.site
else:
site = Site.query.get(1)
return site.default_theme if site.default_theme is not None else ''
else:
return ''