Skip to content

Commit

Permalink
[#3233} Fix recline map config helpers
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
amercader committed Oct 18, 2016
1 parent 39687d9 commit 25839ae
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
20 changes: 6 additions & 14 deletions ckanext/reclineview/plugin.py
Expand Up @@ -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):
'''
Expand All @@ -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',
Expand All @@ -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):
'''
Expand Down Expand Up @@ -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'}]
Expand Down Expand Up @@ -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
}
2 changes: 1 addition & 1 deletion ckanext/reclineview/theme/templates/recline_view.html
Expand Up @@ -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() %}
<div data-module="recline_view"
data-module-site_url="{{ h.dump_json(h.url('/', locale='default', qualified=true)) }}"
data-module-resource = "{{ h.dump_json(resource_json) }}";
Expand Down

0 comments on commit 25839ae

Please sign in to comment.