From 563376ed6cd97debbdc2c0b131c15c9e1c827f11 Mon Sep 17 00:00:00 2001 From: Toby Date: Wed, 28 Mar 2012 15:51:08 +0100 Subject: [PATCH] fix facet_items() --- ckan/lib/helpers.py | 15 ++++++++++++++- ckan/templates/facets.html | 10 +++++----- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/ckan/lib/helpers.py b/ckan/lib/helpers.py index 2e777ca5802..16b0542da70 100644 --- a/ckan/lib/helpers.py +++ b/ckan/lib/helpers.py @@ -321,7 +321,20 @@ def _subnav_named_route(text, routename, **kwargs): def default_group_type(): return str( config.get('ckan.default.group_type', 'group') ) -def facet_items(c, name, limit=10): + +def facet_items(*args, **kwargs): + # facet_items() used to need c passing as the first arg + # this is depriciated as pointless + # throws error if ckan.restrict_template_vars is True + # When we move to strict helpers then this should be removed as a wrapper + if len(args) > 2 or (len(args) > 0 and 'name' in kwargs) or (len(args) > 1 and 'limit' in kwargs): + if not asbool(config.get('ckan.restrict_template_vars', 'false')): + return _facet_items(*args[1:], **kwargs) + raise Exception('facet_items() calling has been changed. remove c in template %s or included one' % c.__template_name) + return _facet_items(*args, **kwargs) + + +def _facet_items(name, limit=10): if not c.facets or not c.facets.get(name): return [] facets = [] diff --git a/ckan/templates/facets.html b/ckan/templates/facets.html index aa47b6d1e22..f50ac3b662f 100644 --- a/ckan/templates/facets.html +++ b/ckan/templates/facets.html @@ -6,17 +6,17 @@ > -
+

${title(code)}

-

${if_empty}

+

${if_empty}

@@ -30,8 +30,8 @@

${title(code)}

If if_empty is not None and there are no facets to filter on, then a single
  • element is generated, with the text specified by if_empty --> -
  • ${if_empty}
  • -
  • ${if_empty}
  • +
  • ${label(name)} (${count})