Move default values defined in settings.py to defaults.py

Some remaining default values of openstack_dashboard are still defined
in settings.py. This commit moves them to openstack_dashboard/defaults.py.
If the default values are same as those defined in horizon,
they are just dropped.

Part of blueprint ini-based-configuration
Change-Id: I723a8f9064450972d4510ac9e8b423f3041d1cac
This commit is contained in:
Akihiro Motoki 2019-04-22 11:47:28 +09:00
parent 9b99f17100
commit 7e95e1601f
3 changed files with 43 additions and 67 deletions

View File

@ -14,6 +14,7 @@
import os
from django.utils.translation import pgettext_lazy
from django.utils.translation import ugettext_lazy as _
# openstack_auth.default is imported in horizon.defaults.
@ -84,6 +85,27 @@ POLICY_DIRS = {
'compute': ['nova_policy.d'],
'volume': ['cinder_policy.d'],
}
POLICY_CHECK_FUNCTION = 'openstack_auth.policy.check'
SITE_BRANDING = 'OpenStack Dashboard'
NG_TEMPLATE_CACHE_AGE = 2592000
# 'key', 'label', 'path'
AVAILABLE_THEMES = [
(
'default',
pgettext_lazy('Default style theme', 'Default'),
'themes/default'
), (
'material',
pgettext_lazy("Google's Material Design style theme", "Material"),
'themes/material'
),
]
# None means to Use AVAILABLE_THEMES as the default value.
SELECTABLE_THEMES = None
# ----------------------------------------
# openstack_dashboard settings
@ -476,6 +498,17 @@ OPENSTACK_CLOUDS_YAML_NAME = 'openstack'
# If this cloud has a vendor profile in os-client-config, put it's name here.
OPENSTACK_CLOUDS_YAML_PROFILE = ''
# Dictionary of currently available angular features
ANGULAR_FEATURES = {
'images_panel': True,
'key_pairs_panel': True,
'flavors_panel': False,
'domains_panel': False,
'users_panel': False,
'groups_panel': False,
'roles_panel': True
}
# AngularJS requires some settings to be made available to
# the client side. Some settings are required by in-tree / built-in horizon
# features. These settings must be added to REST_API_REQUIRED_SETTINGS in the

View File

@ -22,7 +22,6 @@ import os
import sys
import warnings
from django.utils.translation import pgettext_lazy
from django.utils.translation import ugettext_lazy as _
import openstack_auth
@ -56,12 +55,6 @@ if ROOT_PATH not in sys.path:
DEBUG = False
SITE_BRANDING = 'OpenStack Dashboard'
SELECTABLE_THEMES = None
INTEGRATION_TESTS_SUPPORT = False
NG_TEMPLATE_CACHE_AGE = 2592000
ROOT_URLCONF = 'openstack_dashboard.urls'
HORIZON_CONFIG = {
@ -227,45 +220,10 @@ LOCAL_PATH = None
ADD_INSTALLED_APPS = []
# 'key', 'label', 'path'
AVAILABLE_THEMES = [
(
'default',
pgettext_lazy('Default style theme', 'Default'),
'themes/default'
), (
'material',
pgettext_lazy("Google's Material Design style theme", "Material"),
'themes/material'
),
]
# The default theme if no cookie is present
DEFAULT_THEME = 'default'
# Theme Static Directory
THEME_COLLECTION_DIR = 'themes'
# Theme Cookie Name
THEME_COOKIE_NAME = 'theme'
POLICY_CHECK_FUNCTION = 'openstack_auth.policy.check'
CSRF_COOKIE_AGE = None
COMPRESS_OFFLINE_CONTEXT = 'horizon.themes.offline_context'
# Dictionary of currently available angular features
ANGULAR_FEATURES = {
'images_panel': True,
'key_pairs_panel': True,
'flavors_panel': False,
'domains_panel': False,
'users_panel': False,
'groups_panel': False,
'roles_panel': True
}
# Notice all customizable configurations should be above this line
XSTATIC_MODULES = settings_utils.BASE_XSTATIC_MODULES
@ -401,8 +359,6 @@ settings_utils.update_dashboards(
)
INSTALLED_APPS[0:0] = ADD_INSTALLED_APPS
NG_TEMPLATE_CACHE_AGE = NG_TEMPLATE_CACHE_AGE if not DEBUG else 0
# Include xstatic_modules specified in plugin
XSTATIC_MODULES += HORIZON_CONFIG['xstatic_modules']
@ -416,7 +372,7 @@ HORIZON_COMPRESS_OFFLINE_CONTEXT_BASE = {
'WEBROOT': WEBROOT,
'STATIC_URL': STATIC_URL,
'HORIZON_CONFIG': HORIZON_CONFIG,
'NG_TEMPLATE_CACHE_AGE': NG_TEMPLATE_CACHE_AGE,
'NG_TEMPLATE_CACHE_AGE': NG_TEMPLATE_CACHE_AGE if not DEBUG else 0,
}
if DEBUG:

View File

@ -13,8 +13,6 @@
import os
import tempfile
from django.utils.translation import pgettext_lazy
from horizon.test.settings import * # noqa: F403,H303
from horizon.utils.escape import monkeypatch_escape
from horizon.utils import secret_key
@ -60,24 +58,9 @@ TEMPLATES[0]['OPTIONS']['context_processors'].append(
'openstack_dashboard.context_processors.openstack'
)
# 'key', 'label', 'path'
AVAILABLE_THEMES = [
(
'default',
pgettext_lazy('Default style theme', 'Default'),
'themes/default'
), (
'material',
pgettext_lazy("Google's Material Design style theme", "Material"),
'themes/material'
),
]
AVAILABLE_THEMES, SELECTABLE_THEMES, DEFAULT_THEME = \
theme_settings.get_available_themes(AVAILABLE_THEMES, 'default', None)
# Theme Static Directory
THEME_COLLECTION_DIR = 'themes'
COMPRESS_OFFLINE = False
INSTALLED_APPS = (
@ -111,11 +94,12 @@ HORIZON_CONFIG = {
'js_files': [],
}
ANGULAR_FEATURES = {
'images_panel': False, # Use the legacy panel so unit tests are still run
'flavors_panel': False,
'roles_panel': False,
}
# Use the legacy panel so unit tests are still run.
# We need to set False for panels whose default implementation
# is Angular-based.
ANGULAR_FEATURES['images_panel'] = False
ANGULAR_FEATURES['key_pairs_panel'] = False
ANGULAR_FEATURES['roles_panel'] = False
STATICFILES_DIRS = settings_utils.get_xstatic_dirs(
settings_utils.BASE_XSTATIC_MODULES, HORIZON_CONFIG
@ -216,6 +200,9 @@ POLICY_FILES = {
'identity': 'keystone_policy.json',
'compute': 'nova_policy.json'
}
# Tthe policy check is disabled by default in our test, and it is enabled
# when we would like to test the policy check feature itself.
POLICY_CHECK_FUNCTION = None
# The openstack_auth.user.Token object isn't JSON-serializable ATM
SESSION_SERIALIZER = 'django.contrib.sessions.serializers.PickleSerializer'