From a2e30febe25aabcbcb34b4678489655086fa81f2 Mon Sep 17 00:00:00 2001 From: Brook Elgie Date: Fri, 10 Jun 2016 11:25:47 +0100 Subject: [PATCH] [#3103] Use helper for version instead of context Instead of adding the ckan version as a value on `c`, this commit adds a new template helper that returns `ckan.__version__`. --- ckan/lib/base.py | 1 - ckan/lib/helpers.py | 9 ++++++++- ckan/templates/base.html | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ckan/lib/base.py b/ckan/lib/base.py index 72446b366be..01aaa0b04dd 100644 --- a/ckan/lib/base.py +++ b/ckan/lib/base.py @@ -197,7 +197,6 @@ class BaseController(WSGIController): def __before__(self, action, **params): c.__timer = time.time() - c.__version__ = ckan.__version__ app_globals.app_globals._check_uptodate() self._identify_user() diff --git a/ckan/lib/helpers.py b/ckan/lib/helpers.py index 5ae9929416a..9b71151f489 100644 --- a/ckan/lib/helpers.py +++ b/ckan/lib/helpers.py @@ -30,8 +30,8 @@ from routes import redirect_to as _redirect_to from routes import url_for as _routes_default_url_for import i18n -import ckan.exceptions +import ckan.exceptions import ckan.lib.fanstatic_resources as fanstatic_resources import ckan.model as model import ckan.lib.formatters as formatters @@ -41,6 +41,7 @@ import ckan.lib.uploader as uploader import ckan.authz as authz import ckan.plugins as p +import ckan from ckan.common import _, ungettext, g, c, request, session, json @@ -364,6 +365,12 @@ def lang(): return request.environ.get('CKAN_LANG') +@core_helper +def ckan_version(): + '''Return CKAN version''' + return ckan.__version__ + + @core_helper def lang_native_name(lang=None): ''' Return the langage name currently used in it's localised form diff --git a/ckan/templates/base.html b/ckan/templates/base.html index 97f9301d71c..2d13f4eb520 100644 --- a/ckan/templates/base.html +++ b/ckan/templates/base.html @@ -26,7 +26,7 @@ #} {%- block meta -%} - {% block meta_generator %}{% endblock %} + {% block meta_generator %}{% endblock %} {% block meta_viewport %}{% endblock %} {%- endblock -%}