From 69ea33647ea69e5855bb9824657cf956559ee1e5 Mon Sep 17 00:00:00 2001 From: London App Developer Date: Fri, 12 Feb 2016 13:15:09 +0000 Subject: [PATCH] Update plugin.py Prevent the 'harvest' datasets being shown in the group and dataset search results. --- ckanext/harvest/plugin.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ckanext/harvest/plugin.py b/ckanext/harvest/plugin.py index b26c504..9f34de2 100644 --- a/ckanext/harvest/plugin.py +++ b/ckanext/harvest/plugin.py @@ -87,6 +87,17 @@ class Harvest(p.SingletonPlugin, DefaultDatasetForm, DefaultTranslation): return data_dict + def before_search(self, search_params): + '''Prevents the harvesters being shown in dataset search results.''' + + fq = search_params.get('fq', '') + if 'dataset_type:{0}'.format('harvest') not in fq: + fq = "{0} -dataset_type:{1}".format(search_params.get('fq', ''), + 'harvest') + search_params.update({'fq': fq}) + + return search_params + def after_show(self, context, data_dict): if 'type' in data_dict and data_dict['type'] == DATASET_TYPE_NAME: