Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable Resource Type facet in search #227

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions invenio_records_marc21/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@
"field": "is_published",
},
},
"resource_type": {
"facet": facets.resource_type,
"ui": {
"field": "metadata.resource_type",
},
},
"file_type": {
"facet": facets.filetype,
"ui": {
Expand Down Expand Up @@ -83,7 +89,11 @@
}

MARC21_SEARCH_DRAFTS = {
"facets": ["access_status", "is_published", "file_type"],
"facets": [
"resource_type",
"access_status",
"is_published",
],
"sort": [
"bestmatch",
"newest",
Expand All @@ -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",
Expand Down
1 change: 0 additions & 1 deletion invenio_records_marc21/records/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 2 additions & 3 deletions invenio_records_marc21/services/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class Marc21SearchOptions(SearchOptions, SearchOptionsMixin):

facets = {
"access_status": rdm_facets.access_status,
"resource_type": facets.resource_type,
}


Expand All @@ -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,
}


Expand Down Expand Up @@ -90,9 +92,6 @@ class Marc21RecordServiceConfig(RecordServiceConfig, ConfiguratorMixin):
schema_secret_link = None
review = None

# Permission policy
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this change belongs to the resource_type addition?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this change belongs to the resource_type addition?

No this line is a duplet and gets overwritten later in the config.

default_files_enabled = FromConfig("RDM_DEFAULT_FILES_ENABLED", default=True)

permission_policy_cls = FromConfig(
"MARC21_PERMISSION_POLICY",
default=Marc21RecordPermissionPolicy,
Expand Down
12 changes: 12 additions & 0 deletions invenio_records_marc21/services/facets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand All @@ -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"),
},
)