Commit 054500e7 by Nate Hardison Committed by Jason Bau

Use settings context processor for templates

Enable the Django settings context processor (from
https://github.com/mfogel/django-settings-context-processor) and add
a few `TEMPLATE_VISIBLE_SETTINGS`. This will be immediately useful
for accessing the settings in Django templates, since the Mako
middleware already adds settings into the templates' context by
default.
parent 56720ed1
...@@ -204,6 +204,9 @@ TEMPLATE_CONTEXT_PROCESSORS = ( ...@@ -204,6 +204,9 @@ TEMPLATE_CONTEXT_PROCESSORS = (
# Hack to get required link URLs to password reset templates # Hack to get required link URLs to password reset templates
'mitxmako.shortcuts.marketing_link_context_processor', 'mitxmako.shortcuts.marketing_link_context_processor',
# Include TEMPLATE_VISIBLE_SETTINGS in templates
'settings_context_processor.context_processors.settings'
) )
STUDENT_FILEUPLOAD_MAX_SIZE = 4 * 1000 * 1000 # 4 MB STUDENT_FILEUPLOAD_MAX_SIZE = 4 * 1000 * 1000 # 4 MB
...@@ -667,6 +670,7 @@ INSTALLED_APPS = ( ...@@ -667,6 +670,7 @@ INSTALLED_APPS = (
'django.contrib.sessions', 'django.contrib.sessions',
'django.contrib.sites', 'django.contrib.sites',
'djcelery', 'djcelery',
'settings_context_processor',
'south', 'south',
# Monitor the status of services # Monitor the status of services
...@@ -733,6 +737,16 @@ MKTG_URL_LINK_MAP = { ...@@ -733,6 +737,16 @@ MKTG_URL_LINK_MAP = {
'PRIVACY': 'privacy_edx', 'PRIVACY': 'privacy_edx',
} }
######################### VISIBLE SETTINGS ###########################
# These settings' values will be exposed to all templates
TEMPLATE_VISIBLE_SETTINGS = [
"FAVICON_PATH",
"MITX_FEATURES",
"PLATFORM_NAME",
"SITE_NAME",
# TODO: augment me
]
############################### THEME ################################ ############################### THEME ################################
def enable_theme(theme_name): def enable_theme(theme_name):
""" """
...@@ -748,6 +762,9 @@ def enable_theme(theme_name): ...@@ -748,6 +762,9 @@ def enable_theme(theme_name):
""" """
MITX_FEATURES['USE_CUSTOM_THEME'] = True MITX_FEATURES['USE_CUSTOM_THEME'] = True
# Ensure the theme name is visible in templates
TEMPLATE_VISIBLE_SETTINGS.append("THEME_NAME")
# Calculate the location of the theme's files # Calculate the location of the theme's files
theme_root = ENV_ROOT / "themes" / theme_name theme_root = ENV_ROOT / "themes" / theme_name
......
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