template loader: look in additional portal-user locations (#67547)
This commit is contained in:
parent
1300ef7901
commit
c3ab8b78b7
|
@ -131,6 +131,7 @@ class TemplateVars(FileBaseSettingsLoader):
|
|||
def get_hobo_json_variables(cls, hobo_json):
|
||||
variables = hobo_json.get('variables', {})
|
||||
variables['is_portal_agent'] = False
|
||||
variables['is_portal_user'] = False
|
||||
|
||||
authentic_service = None
|
||||
|
||||
|
@ -163,6 +164,8 @@ class TemplateVars(FileBaseSettingsLoader):
|
|||
|
||||
if 'portal-agent' in service.get('template_name', ''):
|
||||
variables['is_portal_agent'] = True
|
||||
elif service.get('service-id') == 'combo':
|
||||
variables['is_portal_user'] = True
|
||||
|
||||
if getattr(settings, 'HOBO_MANAGER_HOMEPAGE_TITLE_VAR', None):
|
||||
variables['manager_homepage_title'] = variables.get(settings.HOBO_MANAGER_HOMEPAGE_TITLE_VAR)
|
||||
|
|
|
@ -4,6 +4,7 @@ to load templates from them in order, caching the result.
|
|||
"""
|
||||
|
||||
import hashlib
|
||||
import itertools
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
|
@ -46,9 +47,41 @@ class FilesystemLoader(DjangoFilesystemLoader):
|
|||
if hasattr(settings, 'TEMPLATE_VARS'):
|
||||
if settings.TEMPLATE_VARS.get('theme'):
|
||||
theme_value = settings.TEMPLATE_VARS['theme']
|
||||
known_dirnames = [
|
||||
'%s/variants/%s' % (x, theme_value) for x in known_dirnames
|
||||
] + known_dirnames
|
||||
if settings.TEMPLATE_VARS.get('is_portal_agent'):
|
||||
known_dirnames = (
|
||||
list(
|
||||
itertools.chain(
|
||||
*[
|
||||
(
|
||||
'%s/variants/%s/portal-agent' % (x, theme_value),
|
||||
'%s/variants/%s' % (x, theme_value),
|
||||
)
|
||||
for x in known_dirnames
|
||||
]
|
||||
)
|
||||
)
|
||||
+ known_dirnames
|
||||
)
|
||||
elif settings.TEMPLATE_VARS.get('is_portal_user'):
|
||||
known_dirnames = (
|
||||
list(
|
||||
itertools.chain(
|
||||
*[
|
||||
(
|
||||
'%s/variants/%s/portal-user' % (x, theme_value),
|
||||
'%s/variants/%s' % (x, theme_value),
|
||||
)
|
||||
for x in known_dirnames
|
||||
]
|
||||
)
|
||||
)
|
||||
+ known_dirnames
|
||||
)
|
||||
else:
|
||||
known_dirnames = [
|
||||
'%s/variants/%s' % (x, theme_value) for x in known_dirnames
|
||||
] + known_dirnames
|
||||
|
||||
if settings.TEMPLATE_VARS.get('is_portal_agent'):
|
||||
known_dirnames = ['%s/portal-agent' % x for x in known_dirnames] + known_dirnames
|
||||
|
||||
|
|
Loading…
Reference in New Issue