Commit 08c9fd94 by David Baumgold

Do theme post-processing in startup hook

parent eeb5f812
...@@ -188,14 +188,6 @@ BULK_EMAIL_ROUTING_KEY = HIGH_PRIORITY_QUEUE ...@@ -188,14 +188,6 @@ BULK_EMAIL_ROUTING_KEY = HIGH_PRIORITY_QUEUE
# Theme overrides # Theme overrides
THEME_NAME = ENV_TOKENS.get('THEME_NAME', None) THEME_NAME = ENV_TOKENS.get('THEME_NAME', None)
# Workaround for setting THEME_NAME to an empty
# string which is the default due to this ansible
# bug: https://github.com/ansible/ansible/issues/4812
if THEME_NAME == "":
THEME_NAME = None
if not THEME_NAME is None:
enable_theme(THEME_NAME)
FAVICON_PATH = 'themes/%s/images/favicon.ico' % THEME_NAME
# Marketing link overrides # Marketing link overrides
MKTG_URL_LINK_MAP.update(ENV_TOKENS.get('MKTG_URL_LINK_MAP', {})) MKTG_URL_LINK_MAP.update(ENV_TOKENS.get('MKTG_URL_LINK_MAP', {}))
......
...@@ -1038,33 +1038,6 @@ MKTG_URL_LINK_MAP = { ...@@ -1038,33 +1038,6 @@ MKTG_URL_LINK_MAP = {
} }
############################### THEME ################################
def enable_theme(theme_name):
"""
Enable the settings for a custom theme, whose files should be stored
in ENV_ROOT/themes/THEME_NAME (e.g., edx_all/themes/stanford).
The THEME_NAME setting should be configured separately since it can't
be set here (this function closes too early). An idiom for doing this
is:
THEME_NAME = "stanford"
enable_theme(THEME_NAME)
"""
FEATURES['USE_CUSTOM_THEME'] = True
# Calculate the location of the theme's files
theme_root = ENV_ROOT / "themes" / theme_name
# Include the theme's templates in the template search paths
TEMPLATE_DIRS.append(theme_root / 'templates')
MAKO_TEMPLATES['main'].append(theme_root / 'templates')
# Namespace the theme's static files to 'themes/<theme_name>' to
# avoid collisions with default edX static files
STATICFILES_DIRS.append((u'themes/%s' % theme_name,
theme_root / 'static'))
################# Student Verification ################# ################# Student Verification #################
VERIFY_STUDENT = { VERIFY_STUDENT = {
"DAYS_GOOD_FOR": 365, # How many days is a verficiation good for? "DAYS_GOOD_FOR": 365, # How many days is a verficiation good for?
......
...@@ -22,3 +22,37 @@ def run(): ...@@ -22,3 +22,37 @@ def run():
if settings.INIT_MODULESTORE_ON_STARTUP: if settings.INIT_MODULESTORE_ON_STARTUP:
for store_name in settings.MODULESTORE: for store_name in settings.MODULESTORE:
modulestore(store_name) modulestore(store_name)
if settings.FEATURES.get('USE_CUSTOM_THEME', False):
enable_theme()
def enable_theme():
"""
Enable the settings for a custom theme, whose files should be stored
in ENV_ROOT/themes/THEME_NAME (e.g., edx_all/themes/stanford).
"""
# Workaround for setting THEME_NAME to an empty
# string which is the default due to this ansible
# bug: https://github.com/ansible/ansible/issues/4812
if settings.THEME_NAME == "":
settings.THEME_NAME = None
return
assert settings.FEATURES['USE_CUSTOM_THEME']
settings.FAVICON_PATH = 'themes/{name}/images/favicon.ico'.format(
name=settings.THEME_NAME
)
# Calculate the location of the theme's files
theme_root = settings.ENV_ROOT / "themes" / settings.THEME_NAME
# Include the theme's templates in the template search paths
settings.TEMPLATE_DIRS.append(theme_root / 'templates')
settings.MAKO_TEMPLATES['main'].append(theme_root / 'templates')
# Namespace the theme's static files to 'themes/<theme_name>' to
# avoid collisions with default edX static files
settings.STATICFILES_DIRS.append(
(u'themes/{}'.format(settings.THEME_NAME), theme_root / 'static')
)
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
## templates have access to these functions, and we can import these ## templates have access to these functions, and we can import these
## into non-inheriting templates via the %namespace tag. ## into non-inheriting templates via the %namespace tag.
<%def name="theme_enabled()"> <%def name="theme_enabled()">
<% return settings.FEATURES["USE_CUSTOM_THEME"] %> <% return settings.FEATURES.get("USE_CUSTOM_THEME", False) %>
</%def> </%def>
<%def name="stanford_theme_enabled()"> <%def name="stanford_theme_enabled()">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment