cleaned up into single flow
This commit is contained in:
parent
77942a7144
commit
54e2615c86
@ -28,81 +28,34 @@ def theme_values(request):
|
|||||||
'logo_color_512': static('assets/logo_color_512.png'),
|
'logo_color_512': static('assets/logo_color_512.png'),
|
||||||
'logo_color_svg': static('assets/logo_color_svg.svg'),
|
'logo_color_svg': static('assets/logo_color_svg.svg'),
|
||||||
'custom_theme': None,
|
'custom_theme': None,
|
||||||
'theme': static(themes[UserPreference.TANDOOR])
|
'theme': static(themes[UserPreference.TANDOOR]),
|
||||||
|
'nav_logo_url': 'assets/brand_logo.png',
|
||||||
}
|
}
|
||||||
space = None
|
space = None
|
||||||
if request.space:
|
if request.space:
|
||||||
space = request.space
|
space = request.space
|
||||||
if UNAUTHENTICATED_THEME_FROM_SPACE > 0: # TODO load unauth space setting on boot in settings.py and use them here
|
if not request.user.is_authenticated and 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()
|
||||||
|
|
||||||
for logo in list(tv.keys()):
|
if request.user.is_authenticated:
|
||||||
print(f'looking for {logo} in {space} has logo {getattr(space, logo, None)}')
|
if request.user.userpreference.theme in themes:
|
||||||
if logo.startswith('logo_color_') and getattr(space, logo, None):
|
tv['theme'] = static(themes[request.user.userpreference.theme])
|
||||||
tv[logo] = getattr(space, logo).file.url
|
|
||||||
|
|
||||||
with scopes_disabled():
|
if space:
|
||||||
if not request.user.is_authenticated and UNAUTHENTICATED_THEME_FROM_SPACE > 0:
|
for logo in list(tv.keys()):
|
||||||
with scopes_disabled():
|
print(f'looking for {logo} in {space} has logo {getattr(space, logo, None)}')
|
||||||
space = Space.objects.filter(id=UNAUTHENTICATED_THEME_FROM_SPACE).first()
|
if logo.startswith('logo_color_') and getattr(space, logo, None):
|
||||||
if space:
|
tv[logo] = getattr(space, logo).file.url
|
||||||
if space.custom_space_theme:
|
|
||||||
tv['custom_theme'] = space.custom_space_theme.file.url
|
|
||||||
if space.space_theme in themes:
|
|
||||||
return static(themes[space.space_theme])
|
|
||||||
|
|
||||||
if request.user.is_authenticated:
|
if space.custom_space_theme:
|
||||||
if request.space.custom_space_theme:
|
tv['custom_theme'] = space.custom_space_theme.file.url
|
||||||
tv['custom_theme'] = request.space.custom_space_theme.file.url
|
if space.space_theme in themes:
|
||||||
if request.space.space_theme in themes:
|
tv['theme'] = static(themes[space.space_theme])
|
||||||
tv['theme'] = themes[request.space.space_theme]
|
|
||||||
else:
|
|
||||||
tv['theme'] = themes[request.user.userpreference.theme]
|
|
||||||
|
|
||||||
return tv
|
return tv
|
||||||
|
|
||||||
|
|
||||||
@register.simple_tag
|
|
||||||
def theme_url(request):
|
|
||||||
themes = {
|
|
||||||
UserPreference.BOOTSTRAP: 'themes/bootstrap.min.css',
|
|
||||||
UserPreference.FLATLY: 'themes/flatly.min.css',
|
|
||||||
UserPreference.DARKLY: 'themes/darkly.min.css',
|
|
||||||
UserPreference.SUPERHERO: 'themes/superhero.min.css',
|
|
||||||
UserPreference.TANDOOR: 'themes/tandoor.min.css',
|
|
||||||
UserPreference.TANDOOR_DARK: 'themes/tandoor_dark.min.css',
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
|
||||||
with scopes_disabled():
|
|
||||||
theme = Space.objects.filter(id=UNAUTHENTICATED_THEME_FROM_SPACE).first().space_theme
|
|
||||||
if theme in themes:
|
|
||||||
return static(themes[theme])
|
|
||||||
else:
|
|
||||||
return static('themes/tandoor.min.css')
|
|
||||||
else:
|
|
||||||
if request.space.space_theme in themes:
|
|
||||||
return static(themes[request.space.space_theme])
|
|
||||||
else:
|
|
||||||
if request.user.userpreference.theme in themes:
|
|
||||||
return static(themes[request.user.userpreference.theme])
|
|
||||||
else:
|
|
||||||
return static('themes/tandoor.min.css')
|
|
||||||
|
|
||||||
|
|
||||||
@register.simple_tag
|
|
||||||
def custom_theme(request):
|
|
||||||
if request.user.is_authenticated and request.space.custom_space_theme:
|
|
||||||
return request.space.custom_space_theme.file.url
|
|
||||||
elif UNAUTHENTICATED_THEME_FROM_SPACE > 0:
|
|
||||||
with scopes_disabled():
|
|
||||||
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
|
||||||
def logo_url(request):
|
def logo_url(request):
|
||||||
if not request.user.is_authenticated:
|
if not request.user.is_authenticated:
|
||||||
|
Loading…
Reference in New Issue
Block a user