From fbdd8b479d3b0a3bdae81ebe5e204d815c14209d Mon Sep 17 00:00:00 2001 From: Henrik Levkowetz Date: Tue, 28 Jul 2015 10:25:58 +0000 Subject: [PATCH] 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 --- ietf/__init__.py | 5 +++++ ietf/checks.py | 22 ++++++++++++++++++++++ ietf/context_processors.py | 4 ++-- ietf/settings.py | 4 +++- 4 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 ietf/checks.py diff --git a/ietf/__init__.py b/ietf/__init__.py index 2f629c3ce..bcac7a1da 100644 --- a/ietf/__init__.py +++ b/ietf/__init__.py @@ -1,7 +1,12 @@ # Copyright The IETF Trust 2007, All Rights Reserved +import checks # pyflakes:ignore +# Don't add patch number here: __version__ = "6.2.1.dev0" +# set this to ".p1", ".p2", etc. after patching +__patch__ = "" + __date__ = "$Date$" __rev__ = "$Rev$ (dev) Latest release: Rev. 9880 " diff --git a/ietf/checks.py b/ietf/checks.py new file mode 100644 index 000000000..4f9c789ef --- /dev/null +++ b/ietf/checks.py @@ -0,0 +1,22 @@ +import os + +from django.conf import settings +from django.core import checks + +@checks.register('directories') +def check_cdn_directory_exists(app_configs, **kwargs): + """This checks that the path from which the CDN will serve static files for + this version of the datatracker actually exists. In development and test + mode this will normally be just STATIC_ROOT, but in production it will be + a symlink to STATIC_ROOT, with a path containing the datatracker release + version. + """ + errors = [] + if not os.path.exists(settings.STATIC_CDN_PATH): + errors.append(checks.Error( + 'The CDN static files path has not been set up', + hint='Set up this symlink:\n\t%s -> %s' % (settings.STATIC_CDN_PATH, settings.STATIC_ROOT), + obj=None, + id='datatracker.E001', + )) + return errors diff --git a/ietf/context_processors.py b/ietf/context_processors.py index 7db015432..29b50b209 100644 --- a/ietf/context_processors.py +++ b/ietf/context_processors.py @@ -1,7 +1,7 @@ # Copyright The IETF Trust 2007, All Rights Reserved from django.conf import settings -from ietf import __date__, __rev__, __version__, __id__ +from ietf import __date__, __rev__, __version__, __patch__, __id__ def server_mode(request): return {'server_mode': settings.SERVER_MODE} @@ -10,4 +10,4 @@ def rfcdiff_base_url(request): return {'rfcdiff_base_url': settings.RFCDIFF_BASE_URL} def revision_info(request): - return {'revision_time': __date__[7:32], 'revision_date': __date__[7:17], 'revision_num': __rev__[6:-2], "revision_id": __id__[5:-2], "version_num": __version__ } + 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__ } diff --git a/ietf/settings.py b/ietf/settings.py index 9cb472168..e0e6e98bb 100644 --- a/ietf/settings.py +++ b/ietf/settings.py @@ -108,8 +108,10 @@ SERVE_CDN_FILES_LOCALLY_IN_DEV_MODE = True # URL to use when referring to static files located in STATIC_ROOT. if SERVER_MODE != 'production' and SERVE_CDN_FILES_LOCALLY_IN_DEV_MODE: STATIC_URL = "/lib/" + STATIC_CDN_PATH = STATIC_ROOT else: STATIC_URL = "https://www.ietf.org/lib/dt/%s/"%__version__ + STATIC_CDN_PATH = "/a/www/www6s/lib/dt/%s/"%__version__ # Destination for components handled by djangobower COMPONENT_ROOT = STATIC_ROOT @@ -119,7 +121,7 @@ COMPONENT_ROOT = STATIC_ROOT STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', - 'ietf.storage.CdnStorageFinder', + 'ietf.utils.storage.CdnStorageFinder', )