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
This commit is contained in:
parent
9c80868187
commit
fbdd8b479d
|
@ -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 "
|
||||
|
|
22
ietf/checks.py
Normal file
22
ietf/checks.py
Normal file
|
@ -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
|
|
@ -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__ }
|
||||
|
|
|
@ -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',
|
||||
)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue