Skip to content
This repository has been archived by the owner on Jan 23, 2025. It is now read-only.

Commit

Permalink
Merge branch 'main' into 173-accidental-custom-fields-when-modifying-…
Browse files Browse the repository at this point in the history
…organisation
  • Loading branch information
A-Souhei authored Oct 2, 2024
2 parents 993243b + 7505f73 commit 682773b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 23 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# ckanext-zarr

Provides tailored styling and features for CKAN for the Zambia Evaluation and Research Repository.
Provides tailored styling and features for CKAN for the Zambia Research and Evaluation Repository.


## Key features
Expand Down
28 changes: 6 additions & 22 deletions ckanext/zarr/helpers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import ckan.logic as logic
import ckan.model as model
from ckan.common import c, request, is_flask_request, g
from ckan.common import request, g
from datetime import datetime, timedelta
from ckan.plugins import toolkit
import html
Expand Down Expand Up @@ -35,43 +35,27 @@ def get_facet_items_dict(
exclude_active -- only return unselected facets.
'''
if search_facets is None:
search_facets = getattr(c, u'search_facets', None)

if not search_facets \
or not isinstance(search_facets, dict) \
or not search_facets.get(facet, {}).get('items'):
return []

facets = []

for facet_item in search_facets.get(facet)['items']:

for facet_item in search_facets[facet]['items']:
if not len(facet_item['name'].strip()):
continue

if is_flask_request():
params_items = request.params.items(multi=True)
else:
params_items = request.params.items()

params_items = request.args.items(multi=True)
if not (facet, facet_item['name']) in params_items:
facets.append(dict(active=False, **facet_item))
elif not exclude_active:
facets.append(dict(active=True, **facet_item))

# Replace CKAN default sort method
facets = _facet_sort_function(facet, facets)

if hasattr(c, 'search_facets_limits'):

if c.search_facets_limits and limit is None:
limit = c.search_facets_limits.get(facet)

if hasattr(g, 'search_facets_limits'):
if g.search_facets_limits and limit is None:
limit = g.search_facets_limits.get(facet)
# zero treated as infinite for hysterical raisins
if limit is not None and limit > 0:
return facets[:limit]

return facets


Expand Down

0 comments on commit 682773b

Please sign in to comment.