Skip to content

Commit c40fc2d

Browse files
committed
Added staticfiles and CDN-related settings to settings.py
- Legacy-Id: 9885
1 parent 1fb8f5a commit c40fc2d

1 file changed

Lines changed: 47 additions & 12 deletions

File tree

ietf/settings.py

Lines changed: 47 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,16 @@
2121

2222
import datetime
2323

24+
from ietf import __version__
25+
2426
DEBUG = True
2527
TEMPLATE_DEBUG = DEBUG
2628

29+
# Valid values:
30+
# 'production', 'test', 'development'
31+
# Override this in settings_local.py if it's not the desired setting:
32+
SERVER_MODE = 'development'
33+
2734
# Domain name of the IETF
2835
IETF_DOMAIN = 'ietf.org'
2936

@@ -91,8 +98,34 @@
9198

9299
MEDIA_URL = 'https://www.ietf.org/'
93100

94-
STATIC_URL = "/"
95-
STATIC_ROOT = os.path.abspath(BASE_DIR + "/../static/")
101+
# Absolute path to the directory static files should be collected to.
102+
# Example: "/var/www/example.com/static/"
103+
STATIC_ROOT = os.path.abspath(BASE_DIR + "/../static/lib/")
104+
105+
106+
SERVE_CDN_FILES_LOCALLY_IN_DEV_MODE = True
107+
108+
# URL to use when referring to static files located in STATIC_ROOT.
109+
if SERVER_MODE != 'production' and SERVE_CDN_FILES_LOCALLY_IN_DEV_MODE:
110+
STATIC_URL = "/lib/"
111+
else:
112+
STATIC_URL = "https://www.ietf.org/lib/dt/%s/"%__version__
113+
114+
# Destination for components handled by djangobower
115+
COMPONENT_ROOT = STATIC_ROOT
116+
117+
# List of finder classes that know how to find static files in
118+
# various locations.
119+
STATICFILES_FINDERS = (
120+
'django.contrib.staticfiles.finders.FileSystemFinder',
121+
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
122+
'ietf.storage.CdnStorageFinder',
123+
)
124+
125+
126+
# Absolute path to the files not served through the staticfiles app
127+
STATIC_LOCAL = os.path.abspath(BASE_DIR + "/../static/")
128+
96129

97130
WSGI_APPLICATION = "ietf.wsgi.application"
98131

@@ -191,19 +224,26 @@ def skip_unreadable_post(record):
191224
'ietf.context_processors.rfcdiff_base_url',
192225
)
193226

227+
# Additional locations of static files
228+
STATICFILES_DIRS = (
229+
os.path.join(BASE_DIR, 'static'),
230+
)
231+
194232
INSTALLED_APPS = (
195233
# Django apps
196-
'django.contrib.auth',
197-
'django.contrib.contenttypes',
198-
'django.contrib.sessions',
199-
'django.contrib.sites',
200-
'django.contrib.sitemaps',
201234
'django.contrib.admin',
202235
'django.contrib.admindocs',
236+
'django.contrib.auth',
237+
'django.contrib.contenttypes',
203238
'django.contrib.humanize',
204239
'django.contrib.messages',
240+
'django.contrib.sessions',
241+
'django.contrib.sitemaps',
242+
'django.contrib.sites',
243+
'django.contrib.staticfiles',
205244
# External apps
206245
'bootstrap3',
246+
'djangobwr',
207247
'form_utils',
208248
'tastypie',
209249
'widget_tweaks',
@@ -278,11 +318,6 @@ def skip_unreadable_post(record):
278318
IDTRACKER_BASE_URL = "https://datatracker.ietf.org"
279319
RFCDIFF_BASE_URL = "https://www.ietf.org/rfcdiff"
280320

281-
# Valid values:
282-
# 'production', 'test', 'development'
283-
# Override this in settings_local.py if it's not true
284-
SERVER_MODE = 'development'
285-
286321
# The name of the method to use to invoke the test suite
287322
TEST_RUNNER = 'ietf.utils.test_runner.IetfTestRunner'
288323

0 commit comments

Comments
 (0)