From 3990cdf9b3fd311e79e1f356d12fa9b14fe2aa8f Mon Sep 17 00:00:00 2001 From: Philipp Gualdi Date: Tue, 9 Jul 2024 09:13:52 +0200 Subject: [PATCH 1/2] feat: resource type to search facets --- invenio_records_marc21/config.py | 17 +++++++++++++++-- invenio_records_marc21/services/config.py | 2 ++ invenio_records_marc21/services/facets.py | 12 ++++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/invenio_records_marc21/config.py b/invenio_records_marc21/config.py index bf2e2b46..da14a535 100644 --- a/invenio_records_marc21/config.py +++ b/invenio_records_marc21/config.py @@ -41,6 +41,12 @@ "field": "is_published", }, }, + "resource_type": { + "facet": facets.resource_type, + "ui": { + "field": "metadata.resource_type", + }, + }, "file_type": { "facet": facets.filetype, "ui": { @@ -83,7 +89,11 @@ } MARC21_SEARCH_DRAFTS = { - "facets": ["access_status", "is_published", "file_type"], + "facets": [ + "resource_type", + "access_status", + "is_published", + ], "sort": [ "bestmatch", "newest", @@ -94,7 +104,10 @@ """User records search configuration (i.e. list of uploads).""" MARC21_SEARCH = { - "facets": ["access_status", "file_type"], + "facets": [ + "resource_type", + "access_status", + ], "sort": [ "bestmatch", "newest", diff --git a/invenio_records_marc21/services/config.py b/invenio_records_marc21/services/config.py index facff332..d89a4740 100644 --- a/invenio_records_marc21/services/config.py +++ b/invenio_records_marc21/services/config.py @@ -52,6 +52,7 @@ class Marc21SearchOptions(SearchOptions, SearchOptionsMixin): facets = { "access_status": rdm_facets.access_status, + "resource_type": facets.resource_type, } @@ -61,6 +62,7 @@ class Marc21SearchDraftsOptions(SearchDraftsOptions, SearchOptionsMixin): facets = { "access_status": rdm_facets.access_status, "is_published": facets.is_published, + "resource_type": facets.resource_type, } diff --git a/invenio_records_marc21/services/facets.py b/invenio_records_marc21/services/facets.py index 92858dad..16d66c84 100644 --- a/invenio_records_marc21/services/facets.py +++ b/invenio_records_marc21/services/facets.py @@ -14,6 +14,8 @@ from invenio_i18n import gettext as _ from invenio_records_resources.services.records.facets import TermsFacet +from ..records.fields.resourcetype import ResourceTypeEnum + is_published = TermsFacet( field="is_published", label=_("Status"), @@ -26,3 +28,13 @@ label=_("File type"), value_labels=lambda ids: {id: id.upper() for id in ids}, ) + + +resource_type = TermsFacet( + field="metadata.fields.970.subfields.d", + label=_("Resource type"), + value_labels={ + ResourceTypeEnum.HSMASTER.value: _("Masterthesis"), + ResourceTypeEnum.HSDISS.value: _("Dissertation"), + }, +) From 80ca73a7299aab64914659640cc050adb5cc067b Mon Sep 17 00:00:00 2001 From: Philipp Gualdi Date: Tue, 9 Jul 2024 09:05:42 +0200 Subject: [PATCH 2/2] style: improve codequality --- invenio_records_marc21/records/api.py | 1 - invenio_records_marc21/services/config.py | 3 --- 2 files changed, 4 deletions(-) diff --git a/invenio_records_marc21/records/api.py b/invenio_records_marc21/records/api.py index a9d4b830..1b4d491e 100644 --- a/invenio_records_marc21/records/api.py +++ b/invenio_records_marc21/records/api.py @@ -16,7 +16,6 @@ from invenio_drafts_resources.records.api import ParentRecord as BaseParentRecord from invenio_drafts_resources.records.systemfields import ParentField from invenio_pidstore.models import PIDStatus -from invenio_rdm_records.records.dumpers import StatisticsDumperExt from invenio_rdm_records.records.systemfields import ( HasDraftCheckField, ParentRecordAccessField, diff --git a/invenio_records_marc21/services/config.py b/invenio_records_marc21/services/config.py index d89a4740..1debaf95 100644 --- a/invenio_records_marc21/services/config.py +++ b/invenio_records_marc21/services/config.py @@ -92,9 +92,6 @@ class Marc21RecordServiceConfig(RecordServiceConfig, ConfiguratorMixin): schema_secret_link = None review = None - # Permission policy - default_files_enabled = FromConfig("RDM_DEFAULT_FILES_ENABLED", default=True) - permission_policy_cls = FromConfig( "MARC21_PERMISSION_POLICY", default=Marc21RecordPermissionPolicy,