diff --git a/ckanext/odsh/plugin.py b/ckanext/odsh/plugin.py index 5db0f85d0a9552f7e712a1a05d349e9be3a24707..335544fa48babdfb29595c842e3928737e4c7628 100644 --- a/ckanext/odsh/plugin.py +++ b/ckanext/odsh/plugin.py @@ -21,9 +21,36 @@ import ckan.plugins as p import logging import validation import precondition + +import sys log = logging.getLogger(__name__) +# from functools import wraps +# from flask import Flask, redirect, jsonify +# app = Flask(__name__) + +# def get_http_exception_handler(app): +# """Overrides the default http exception handler to return JSON.""" +# handle_http_exception = app.handle_http_exception +# @wraps(handle_http_exception) +# def ret_val(exception): +# print("HEHREHR") +# exc = handle_http_exception(exception) +# return jsonify({'code':exc.code, 'message':exc.description}), exc.code +# return ret_val + +# # Override the HTTP exception handler. +# app.handle_http_exception = get_http_exception_handler(app) + + +# def my_except_hook(exctype, value, traceback): +# print('GOT excepton') +# log.exception(value) +# sys.__excepthook__(exctype, value, traceback) +# print('INSTALL EX') +# sys.excepthook = my_except_hook + _ = toolkit._ from multiline_formatter.formatter import MultilineMessagesFormatter @@ -354,6 +381,7 @@ class OdshPlugin(plugins.SingletonPlugin, DefaultTranslation, DefaultDatasetForm # use several daterange queries agains temporal_start and temporal_end field # TODO: use field of type date_range in solr index instead def before_search(self, search_params): + search_params['facet.mincount']=0 extras = search_params.get('extras') if not extras: # There are no extras in the search params, so do nothing. diff --git a/ckanext/odsh/templates/snippets/facet_list.html b/ckanext/odsh/templates/snippets/facet_list.html index 985003d4ecce0793b384884f662b67c257488079..38a8e1a4bcac50baf0dafdcc61bcafe8c9aebb28 100644 --- a/ckanext/odsh/templates/snippets/facet_list.html +++ b/ckanext/odsh/templates/snippets/facet_list.html @@ -7,7 +7,7 @@ {% block facet_list_items %} {# {% with items = items or h.get_facet_items_dict(name,20) %} #} -{% with items = items or h.odsh_get_facet_items_dict(name) %} +{% with items = items or h.odsh_get_facet_items_dict(name)|selectattr('count')|list %} {% if items %} <nav> {% set title = title or h.get_facet_title(name) %}