From 25839ae839236ec651839a8d3dde5da77baf8e7f Mon Sep 17 00:00:00 2001 From: amercader Date: Tue, 6 Sep 2016 14:24:32 +0100 Subject: [PATCH] [#3233} Fix recline map config helpers Previously recline_view and recline_map_view registered to separate names for the same helper function, and the template checked for both. But if you didn't load one of the plugins then you got a HelperError as it hadn't been registered. This makes all recline plugins load the same helper so it only has one name. --- ckanext/reclineview/plugin.py | 20 ++++++------------- .../theme/templates/recline_view.html | 2 +- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/ckanext/reclineview/plugin.py b/ckanext/reclineview/plugin.py index d6ac44f2b98..3c52a3c4e60 100644 --- a/ckanext/reclineview/plugin.py +++ b/ckanext/reclineview/plugin.py @@ -58,6 +58,7 @@ class ReclineViewBase(p.SingletonPlugin): ''' p.implements(p.IConfigurer, inherit=True) p.implements(p.IResourceView, inherit=True) + p.implements(p.ITemplateHelpers, inherit=True) def update_config(self, config): ''' @@ -80,14 +81,17 @@ def setup_template_variables(self, context, data_dict): def view_template(self, context, data_dict): return 'recline_view.html' + def get_helpers(self): + return { + 'get_map_config': get_mapview_config + } + class ReclineView(ReclineViewBase): ''' This extension views resources using a Recline MultiView. ''' - p.implements(p.ITemplateHelpers, inherit=True) - def info(self): return {'name': 'recline_view', 'title': 'Data Explorer', @@ -109,11 +113,6 @@ def can_view(self, data_dict): else: return False - def get_helpers(self): - return { - 'get_map_config': get_mapview_config - } - class ReclineGridView(ReclineViewBase): ''' @@ -190,8 +189,6 @@ class ReclineMapView(ReclineViewBase): This extension views resources using a Recline map. ''' - p.implements(p.ITemplateHelpers, inherit=True) - map_field_types = [{'value': 'lat_long', 'text': 'Latitude / Longitude fields'}, {'value': 'geojson', 'text': 'GeoJSON'}] @@ -252,8 +249,3 @@ def setup_template_variables(self, context, data_dict): def form_template(self, context, data_dict): return 'recline_map_form.html' - - def get_helpers(self): - return { - 'get_mapview_config': get_mapview_config - } diff --git a/ckanext/reclineview/theme/templates/recline_view.html b/ckanext/reclineview/theme/templates/recline_view.html index aff31c8e12e..3271658deff 100644 --- a/ckanext/reclineview/theme/templates/recline_view.html +++ b/ckanext/reclineview/theme/templates/recline_view.html @@ -2,7 +2,7 @@ {% block page %} - {% set map_config = h.get_map_config() or h.get_mapview_config() %} + {% set map_config = h.get_map_config() %}