From f0cbf44fe0b43454ef7933b50a3f9bab7a2814ea Mon Sep 17 00:00:00 2001 From: Josh Humphries Date: Wed, 30 Oct 2024 13:09:33 +0000 Subject: [PATCH] feat: add artefact multisearch group management --- ckanext/nhm/plugin.py | 3 +++ ckanext/nhm/views/artefact.py | 17 +++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 ckanext/nhm/views/artefact.py diff --git a/ckanext/nhm/plugin.py b/ckanext/nhm/plugin.py index 28fbfba1..aa6e1a43 100644 --- a/ckanext/nhm/plugin.py +++ b/ckanext/nhm/plugin.py @@ -36,6 +36,7 @@ from ckanext.nhm.views.specimen import modify_field_groups as specimen_modify_groups from ckanext.nhm.views.indexlot import modify_field_groups as indexlot_modify_groups from ckanext.nhm.views.sample import modify_field_groups as sample_modify_groups +from ckanext.nhm.views.artefact import modify_field_groups as artefact_modify_groups try: from ckanext.status.interfaces import IStatus @@ -552,6 +553,8 @@ def vds_modify_field_groups(self, resource_ids, field_groups): indexlot_modify_groups(field_groups) if helpers.get_sample_resource_id() in resource_ids: sample_modify_groups(field_groups) + if helpers.get_artefact_resource_id() in resource_ids: + artefact_modify_groups(field_groups) return field_groups def datastore_before_convert_basic_query(self, query): diff --git a/ckanext/nhm/views/artefact.py b/ckanext/nhm/views/artefact.py new file mode 100644 index 00000000..ad816783 --- /dev/null +++ b/ckanext/nhm/views/artefact.py @@ -0,0 +1,17 @@ +def modify_field_groups(field_groups): + """ + Given a FieldGroups object from the vds plugin, force certain field groups to show + in multisearch results and force certain field groups to be ignored and not shown. + + :param field_groups: a FieldGroups object + """ + # forces + field_groups.force("artefactName") + field_groups.force("scientificName") + field_groups.force("") + field_groups.force("artefactType") + field_groups.force("associatedMediaCount") + # ignores + field_groups.ignore("created") + field_groups.ignore("modified") + field_groups.ignore("associatedMedia.*")