fxied theming tags

This commit is contained in:
vabene1111 2024-01-07 16:55:12 +08:00
parent f9bfb8e258
commit 1dda4126c1

View File

@ -49,7 +49,9 @@ def theme_url(request):
if not request.user.is_authenticated: if not request.user.is_authenticated:
if UNAUTHENTICATED_THEME_FROM_SPACE > 0: # TODO load unauth space setting on boot in settings.py and use them here if UNAUTHENTICATED_THEME_FROM_SPACE > 0: # TODO load unauth space setting on boot in settings.py and use them here
with scopes_disabled(): with scopes_disabled():
return static(themes[Space.objects.filter(id=UNAUTHENTICATED_THEME_FROM_SPACE).first().space_theme]) theme = Space.objects.filter(id=UNAUTHENTICATED_THEME_FROM_SPACE).first().space_theme
if theme in themes:
return static(themes[theme])
else: else:
return static('themes/tandoor.min.css') return static('themes/tandoor.min.css')
@ -68,7 +70,9 @@ def custom_theme(request):
return request.space.custom_space_theme.file.url return request.space.custom_space_theme.file.url
elif UNAUTHENTICATED_THEME_FROM_SPACE > 0: elif UNAUTHENTICATED_THEME_FROM_SPACE > 0:
with scopes_disabled(): with scopes_disabled():
return Space.objects.filter(id=UNAUTHENTICATED_THEME_FROM_SPACE).first().custom_space_theme.file.url space = Space.objects.filter(id=UNAUTHENTICATED_THEME_FROM_SPACE).first()
if space.custom_space_theme:
return space.custom_space_theme.file.url
@register.simple_tag @register.simple_tag
@ -109,7 +113,7 @@ def nav_text_color(request):
if UNAUTHENTICATED_THEME_FROM_SPACE > 0: if UNAUTHENTICATED_THEME_FROM_SPACE > 0:
with scopes_disabled(): with scopes_disabled():
space = Space.objects.filter(id=UNAUTHENTICATED_THEME_FROM_SPACE).first() space = Space.objects.filter(id=UNAUTHENTICATED_THEME_FROM_SPACE).first()
if space.nav_text_color: if space.nav_text_color and space.nav_text_color in type_mapping:
return type_mapping[space.nav_text_color] return type_mapping[space.nav_text_color]
return 'navbar-light' return 'navbar-light'
else: else: