Allow extent map to be shown on configurable routes.

This commit is contained in:
David Read 2012-04-27 10:44:15 +01:00
parent 202ee80893
commit 8f4ae04570
2 changed files with 9 additions and 3 deletions

View File

@ -77,6 +77,11 @@ Coordinates must be in latitude/longitude, e.g.::
ckan.spatial.default_map_extent=-6.88,49.74,0.50,59.2
The Dataset Extent Map displays only on certain routes. By default it is just the 'Package' controller, 'read' method. To display it on other routes you can specify it in a space separated list like this::
ckan.spatial.dataset_extent_map.routes = package/read ckanext.dgu.controllers.package:PackageController/read
SOLR Configuration
------------------

View File

@ -174,9 +174,10 @@ class DatasetExtentMap(SingletonPlugin):
def filter(self, stream):
from pylons import request, tmpl_context as c
routes = request.environ.get('pylons.routes_dict')
if routes.get('controller') == 'package' and \
routes.get('action') == 'read' and c.pkg.id:
route_dict = request.environ.get('pylons.routes_dict')
route = '%s/%s' % (route_dict.get('controller'), route_dict.get('action'))
routes_to_filter = config.get('ckan.spatial.dataset_extent_map.routes', 'package/read').split(' ')
if route in routes_to_filter and c.pkg.id:
extent = c.pkg.extras.get('spatial',None)
if extent: