Skip to content

Commit

Permalink
[#3103] Use helper for version instead of context
Browse files Browse the repository at this point in the history
Instead of adding the ckan version as a value on `c`, this commit adds a
new template helper that returns `ckan.__version__`.
  • Loading branch information
brew committed Jun 10, 2016
1 parent 997b06c commit a2e30fe
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
1 change: 0 additions & 1 deletion ckan/lib/base.py
Expand Up @@ -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()
Expand Down
9 changes: 8 additions & 1 deletion ckan/lib/helpers.py
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ckan/templates/base.html
Expand Up @@ -26,7 +26,7 @@
#}
{%- block meta -%}
<meta charset="utf-8" />
{% block meta_generator %}<meta name="generator" content="ckan {{ c.__version__ }}" />{% endblock %}
{% block meta_generator %}<meta name="generator" content="ckan {{ h.ckan_version() }}" />{% endblock %}
{% block meta_viewport %}<meta name="viewport" content="width=device-width, initial-scale=1.0">{% endblock %}
{%- endblock -%}

Expand Down

0 comments on commit a2e30fe

Please sign in to comment.