Move static files configuration to reduce settings.py churn

Operators don't like it when we change settings.py a lot, so this change
moves application configuration code (which can change a bunch) out of
settings.py into a separate file.

Change-Id: If099aa0d5d24827b1ce301f7c586647e6617826d
Closes-Bug: 1475447
This commit is contained in:
Richard Jones 2015-07-17 15:58:34 +10:00
parent c06d782e4a
commit 8c9d9a8fed
2 changed files with 32 additions and 25 deletions

View File

@ -25,6 +25,7 @@ import django
from django.utils.translation import ugettext_lazy as _
from openstack_dashboard import exceptions
from openstack_dashboard.static_settings import find_static_files # noqa
from openstack_dashboard.static_settings import get_staticfiles_dirs # noqa
@ -305,31 +306,7 @@ STATICFILES_DIRS.append(
# populate HORIZON_CONFIG with auto-discovered JavaScript sources, mock files,
# specs files and external templates.
from horizon.utils import file_discovery as fd
# note the path must end in a '/' or the resultant file paths will have a
# leading "/"
fd.populate_horizon_config(
HORIZON_CONFIG,
os.path.join(ROOT_PATH, '..', 'horizon', 'static/')
)
# filter out non-angular javascript code and lib
HORIZON_CONFIG['js_files'] = ([f for f in HORIZON_CONFIG['js_files']
if not f.startswith('horizon/')])
# note the path must end in a '/' or the resultant file paths will have a
# leading "/"
fd.populate_horizon_config(
HORIZON_CONFIG,
os.path.join(ROOT_PATH, 'static/'),
sub_path='openstack-service-api/'
)
fd.populate_horizon_config(
HORIZON_CONFIG,
os.path.join(ROOT_PATH, 'static/'),
sub_path='app/core/'
)
find_static_files(ROOT_PATH, HORIZON_CONFIG)
# Load the pluggable dashboard settings
import openstack_dashboard.enabled

View File

@ -17,6 +17,8 @@ distributions can edit or replace this file, in order to change the paths
to match their distribution's standards.
"""
import os
import xstatic.main
import xstatic.pkg.angular
import xstatic.pkg.angular_bootstrap
@ -40,6 +42,8 @@ import xstatic.pkg.rickshaw
import xstatic.pkg.spin
import xstatic.pkg.termjs
from horizon.utils import file_discovery
def get_staticfiles_dirs(webroot='/'):
STATICFILES_DIRS = [
@ -121,3 +125,29 @@ def get_staticfiles_dirs(webroot='/'):
root_url=webroot).base_dir))
return STATICFILES_DIRS
def find_static_files(ROOT_PATH, HORIZON_CONFIG):
# note the path must end in a '/' or the resultant file paths will have a
# leading "/"
file_discovery.populate_horizon_config(
HORIZON_CONFIG,
os.path.join(ROOT_PATH, '..', 'horizon', 'static/')
)
# filter out non-angular javascript code and lib
HORIZON_CONFIG['js_files'] = ([f for f in HORIZON_CONFIG['js_files']
if not f.startswith('horizon/')])
# note the path must end in a '/' or the resultant file paths will have a
# leading "/"
file_discovery.populate_horizon_config(
HORIZON_CONFIG,
os.path.join(ROOT_PATH, 'static/'),
sub_path='openstack-service-api/'
)
file_discovery.populate_horizon_config(
HORIZON_CONFIG,
os.path.join(ROOT_PATH, 'static/'),
sub_path='app/core/'
)