From ec775eda559318ca03976a371583224c1bab9d92 Mon Sep 17 00:00:00 2001 From: Stefan Oderbolz Date: Tue, 30 Jun 2015 17:50:02 +0200 Subject: [PATCH] [#2494] Add a new API endpoint to set timezone offset --- ckan/config/routing.py | 1 + ckan/controllers/util.py | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ckan/config/routing.py b/ckan/config/routing.py index 4f92b715991..abadcce83aa 100644 --- a/ckan/config/routing.py +++ b/ckan/config/routing.py @@ -443,6 +443,7 @@ def make_map(): with SubMapper(map, controller='util') as m: m.connect('/i18n/strings_{lang}.js', action='i18n_js_strings') + m.connect('/util/set_timezone_offset/{offset}', action='set_timezone_offset') m.connect('/util/redirect', action='redirect') m.connect('/testing/primer', action='primer') m.connect('/testing/markup', action='markup') diff --git a/ckan/controllers/util.py b/ckan/controllers/util.py index 840c6833a04..e563fdff9a3 100644 --- a/ckan/controllers/util.py +++ b/ckan/controllers/util.py @@ -3,7 +3,7 @@ import ckan.lib.base as base import ckan.lib.i18n as i18n import ckan.lib.helpers as h -from ckan.common import _ +from ckan.common import _, request class UtilController(base.BaseController): @@ -25,6 +25,12 @@ def primer(self): This is useful for development/styling of ckan. ''' return base.render('development/primer.html') + def set_timezone_offset(self, offset): + session = request.environ['beaker.session'] + session['utc_offset_mins'] = offset + session.save() + return session.get('utc_offset_mins', 'No offset set') + def markup(self): ''' Render all html elements out onto a single page. This is useful for development/styling of ckan. '''