Skip to content

Commit fbdd8b4

Browse files
committed
Added a check for the existence of the CDN static path using the new (Django 1.7) checks framework. Split the release version and patch string in order to not move the expected CDN static files location when adding a patch indicator to the version number.
- Legacy-Id: 9906
1 parent 9c80868 commit fbdd8b4

4 files changed

Lines changed: 32 additions & 3 deletions

File tree

ietf/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
# Copyright The IETF Trust 2007, All Rights Reserved
2+
import checks # pyflakes:ignore
23

4+
# Don't add patch number here:
35
__version__ = "6.2.1.dev0"
46

7+
# set this to ".p1", ".p2", etc. after patching
8+
__patch__ = ""
9+
510
__date__ = "$Date$"
611

712
__rev__ = "$Rev$ (dev) Latest release: Rev. 9880 "

ietf/checks.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import os
2+
3+
from django.conf import settings
4+
from django.core import checks
5+
6+
@checks.register('directories')
7+
def check_cdn_directory_exists(app_configs, **kwargs):
8+
"""This checks that the path from which the CDN will serve static files for
9+
this version of the datatracker actually exists. In development and test
10+
mode this will normally be just STATIC_ROOT, but in production it will be
11+
a symlink to STATIC_ROOT, with a path containing the datatracker release
12+
version.
13+
"""
14+
errors = []
15+
if not os.path.exists(settings.STATIC_CDN_PATH):
16+
errors.append(checks.Error(
17+
'The CDN static files path has not been set up',
18+
hint='Set up this symlink:\n\t%s -> %s' % (settings.STATIC_CDN_PATH, settings.STATIC_ROOT),
19+
obj=None,
20+
id='datatracker.E001',
21+
))
22+
return errors

ietf/context_processors.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright The IETF Trust 2007, All Rights Reserved
22

33
from django.conf import settings
4-
from ietf import __date__, __rev__, __version__, __id__
4+
from ietf import __date__, __rev__, __version__, __patch__, __id__
55

66
def server_mode(request):
77
return {'server_mode': settings.SERVER_MODE}
@@ -10,4 +10,4 @@ def rfcdiff_base_url(request):
1010
return {'rfcdiff_base_url': settings.RFCDIFF_BASE_URL}
1111

1212
def revision_info(request):
13-
return {'revision_time': __date__[7:32], 'revision_date': __date__[7:17], 'revision_num': __rev__[6:-2], "revision_id": __id__[5:-2], "version_num": __version__ }
13+
return {'revision_time': __date__[7:32], 'revision_date': __date__[7:17], 'revision_num': __rev__[6:-2], "revision_id": __id__[5:-2], "version_num": __version__+__patch__ }

ietf/settings.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,10 @@
108108
# URL to use when referring to static files located in STATIC_ROOT.
109109
if SERVER_MODE != 'production' and SERVE_CDN_FILES_LOCALLY_IN_DEV_MODE:
110110
STATIC_URL = "/lib/"
111+
STATIC_CDN_PATH = STATIC_ROOT
111112
else:
112113
STATIC_URL = "https://www.ietf.org/lib/dt/%s/"%__version__
114+
STATIC_CDN_PATH = "/a/www/www6s/lib/dt/%s/"%__version__
113115

114116
# Destination for components handled by djangobower
115117
COMPONENT_ROOT = STATIC_ROOT
@@ -119,7 +121,7 @@
119121
STATICFILES_FINDERS = (
120122
'django.contrib.staticfiles.finders.FileSystemFinder',
121123
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
122-
'ietf.storage.CdnStorageFinder',
124+
'ietf.utils.storage.CdnStorageFinder',
123125
)
124126

125127

0 commit comments

Comments
 (0)