Skip to content
Snippets Groups Projects
Commit 55bf992d authored by anonymous's avatar anonymous
Browse files

fix facet filter

parent c55f18ef
Branches
Tags
No related merge requests found
...@@ -12,6 +12,7 @@ from ckan.common import config ...@@ -12,6 +12,7 @@ from ckan.common import config
import urllib import urllib
import hashlib import hashlib
import re import re
from ckan.common import request
get_action = logic.get_action get_action = logic.get_action
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
...@@ -194,3 +195,19 @@ def presorted_license_options(existing_license_id=None): ...@@ -194,3 +195,19 @@ def presorted_license_options(existing_license_id=None):
(license_id, (license_id,
register[license_id].title if license_id in register else license_id) register[license_id].title if license_id in register else license_id)
for license_id in license_ids] for license_id in license_ids]
def odsh_has_more_facets(facet, limit=None, exclude_active=False):
facets = []
for facet_item in c.search_facets.get(facet)['items']:
if not len(facet_item['name'].strip()) or facet_item['count']==0:
continue
if not (facet, facet_item['name']) in request.params.items():
facets.append(dict(active=False, **facet_item))
elif not exclude_active:
facets.append(dict(active=True, **facet_item))
if c.search_facets_limits and limit is None:
limit = c.search_facets_limits.get(facet)
if limit is not None and len(facets) > limit:
return True
return False
...@@ -248,7 +248,8 @@ class OdshPlugin(plugins.SingletonPlugin, DefaultTranslation, DefaultDatasetForm ...@@ -248,7 +248,8 @@ class OdshPlugin(plugins.SingletonPlugin, DefaultTranslation, DefaultDatasetForm
'odsh_create_checksum': odsh_helpers.odsh_create_checksum, 'odsh_create_checksum': odsh_helpers.odsh_create_checksum,
'presorted_license_options': odsh_helpers.presorted_license_options, 'presorted_license_options': odsh_helpers.presorted_license_options,
'odsh_tracking_id': odsh_helpers.odsh_tracking_id, 'odsh_tracking_id': odsh_helpers.odsh_tracking_id,
'odsh_tracking_url': odsh_helpers.odsh_tracking_url 'odsh_tracking_url': odsh_helpers.odsh_tracking_url,
'odsh_has_more_facets': odsh_helpers.odsh_has_more_facets
} }
def after_map(self, map): def after_map(self, map):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment