From 15ac2261eb508dc8cb86046304da4e57ef3c678d Mon Sep 17 00:00:00 2001 From: Bo Wang Date: Thu, 17 Dec 2015 14:16:35 +0800 Subject: [PATCH] Ensure horizon configurations could be customized Users could customize horizon configuration items in two ways: 1. overwrite item values in "local_settings.py". 2. add *.py into local_settings.d/. ref:https://review.openstack.org/#/c/243974/6 To ensure the two ways work, we should move all customizable configurations above the two ways in settings.py. Otherwise, configurations in settings.py are the real final values. Change-Id: I3b6a04d8bd8ec540b1f8efac93465317a0c1008d Closes-Bug: #1527042 --- openstack_dashboard/settings.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/openstack_dashboard/settings.py b/openstack_dashboard/settings.py index 951733a848..cb6031476b 100644 --- a/openstack_dashboard/settings.py +++ b/openstack_dashboard/settings.py @@ -48,6 +48,8 @@ WEBROOT = '/' LOGIN_URL = None LOGOUT_URL = None LOGIN_REDIRECT_URL = None +MEDIA_ROOT = None +MEDIA_URL = None STATIC_ROOT = None STATIC_URL = None @@ -287,6 +289,13 @@ THEME_COLLECTION_DIR = 'themes' # Theme Cookie Name THEME_COOKIE_NAME = 'theme' +POLICY_CHECK_FUNCTION = None + +CSRF_COOKIE_AGE = None + +COMPRESS_OFFLINE_CONTEXT = 'horizon.themes.offline_context' + +# Notice all customizable configurations should be above this line try: from local.local_settings import * # noqa except ImportError: @@ -326,8 +335,11 @@ if LOGOUT_URL is None: if LOGIN_REDIRECT_URL is None: LOGIN_REDIRECT_URL = WEBROOT -MEDIA_ROOT = os.path.abspath(os.path.join(ROOT_PATH, '..', 'media')) -MEDIA_URL = WEBROOT + 'media/' +if MEDIA_ROOT is None: + MEDIA_ROOT = os.path.abspath(os.path.join(ROOT_PATH, '..', 'media')) + +if MEDIA_URL is None: + MEDIA_URL = WEBROOT + 'media/' if STATIC_ROOT is None: STATIC_ROOT = os.path.abspath(os.path.join(ROOT_PATH, '..', 'static')) @@ -395,7 +407,8 @@ def check(actions, request, target=None): from openstack_auth import policy return policy.check(actions, request, target=None) -POLICY_CHECK_FUNCTION = check +if POLICY_CHECK_FUNCTION is None: + POLICY_CHECK_FUNCTION = check # This base context objects gets added to the offline context generator # for each theme configured. @@ -405,9 +418,5 @@ HORIZON_COMPRESS_OFFLINE_CONTEXT_BASE = { 'HORIZON_CONFIG': HORIZON_CONFIG } -COMPRESS_OFFLINE_CONTEXT = 'horizon.themes.offline_context' - if DEBUG: logging.basicConfig(level=logging.DEBUG) - -CSRF_COOKIE_AGE = None