diff --git a/invenio/invenio.cfg b/invenio/invenio.cfg index 4b4543c..a0ba8f5 100644 --- a/invenio/invenio.cfg +++ b/invenio/invenio.cfg @@ -11,59 +11,45 @@ https://inveniordm.docs.cern.ch/reference/configuration/. from copy import deepcopy from datetime import datetime -import re -from flask import request, url_for + import idutils -from marshmallow import validate -from invenio_rdm_records.services.pids import providers -from invenio_rdm_records.services import facets +from invenio_access import action_factory + +from invenio_communities.communities.records.models import CommunityMetadata +from invenio_communities.permissions import CommunityPermissionPolicy +from invenio_db import db from invenio_rdm_records.contrib.journal import ( JOURNAL_CUSTOM_FIELDS, JOURNAL_CUSTOM_FIELDS_UI, JOURNAL_NAMESPACE, ) +from invenio_rdm_records.services import facets +from invenio_rdm_records.services.generators import ( + AccessGrant, + IfRestricted, + RecordOwners, +) +from invenio_rdm_records.services.permissions import RDMRecordPermissionPolicy +from invenio_rdm_records.services.pids import providers +from invenio_records.dictutils import dict_lookup +from invenio_records_permissions.generators import ( + AuthenticatedUser, + ConditionalGenerator, + Generator, + SystemProcess, +) from invenio_records_resources.services.custom_fields import TextCF +from invenio_records_resources.services.records.facets.facets import TermsFacet from invenio_records_resources.services.records.queryparser import ( FieldValueMapper, QueryParser, SearchFieldTransformer, ) - -# from invenio_records_resources.services.records.facets import TermsFacet -from invenio_communities.communities.records.models import CommunityMetadata -from invenio_db import db +from invenio_vocabularies.contrib.affiliations.facets import AffiliationsLabels +from invenio_vocabularies.contrib.funders.facets import FundersLabels +from invenio_vocabularies.services.facets import VocabularyLabels from luqum.tree import Phrase - -from invenio_access import action_factory -from invenio_records.dictutils import dict_lookup -from invenio_records_permissions.generators import ( - ConditionalGenerator, - Generator, -) -from invenio_administration.generators import Administration -from invenio_communities.permissions import CommunityPermissionPolicy -from invenio_rdm_records.services.generators import ( - AccessGrant, - CommunityInclusionReviewers, - IfDeleted, - IfExternalDOIRecord, - IfFileIsLocal, - IfNewRecord, - IfRecordDeleted, - IfRestricted, - RecordCommunitiesAction, - RecordOwners, - ResourceAccessToken, - SecretLinks, - SubmissionReviewer, -) -from invenio_rdm_records.services.permissions import RDMRecordPermissionPolicy -from invenio_records_permissions.generators import ( - AuthenticatedUser, - Disable, - IfConfig, - SystemProcess, -) +from marshmallow import validate def _(x): # needed to avoid start time failure with lazy strings @@ -176,7 +162,7 @@ I18N_LANGUAGES = [ # See https://invenio-mail.readthedocs.io/en/latest/configuration.html # Set this to False when enable email sending. -MAIL_SUPPRESS_SEND = True +MAIL_SUPPRESS_SEND = False # Invenio-Theme # ============= @@ -193,6 +179,14 @@ THEME_FRONTPAGE_SUBTITLE = ( # Header logo THEME_LOGO = "images/starter.svg" +# Invenio-logging Sentry +# ---------------------- +LOGGING_SENTRY_INIT_KWARGS = { + # Add Sentry SDK configuration options here, e.g.: + # Instruct Sentry to send user data attached to the event + "send_default_pii": True, +} +LOGGING_SENTRY_LEVEL = "ERROR" # Invenio-App-RDM # =============== @@ -203,6 +197,7 @@ INSTANCE_THEME_FILE = "./less/theme.less" # Invenio-Files-Rest # ================== +DATADIR = "/opt/invenio/var/instance/data" FILES_REST_STORAGE_FACTORY = "invenio_s3.s3fs_storage_factory" FILES_REST_MAX_CONTENT_LENGTH = 5 * 1024**4 # 5 TB total FILES_REST_MULTIPART_CHUNKSIZE_MIN = 5 * 1024**2 # 5 MB (S3 minimum) @@ -231,6 +226,11 @@ S3_DEFAULT_BLOCK_SIZE = 525 * 1024**2 # 525 MB S3_SIGNATURE_VERSION = "s3v4" S3_ARGS = {"ACL": "private", "ServerSideEncryption": "AES256"} +# Invenio-Assets +# ============== +# Use rspack instead of webpack +WEBPACKEXT_PROJECT = "invenio_assets.webpack:rspack_project" + # Invenio-Records-Resources # ========================= # See https://github.com/inveniosoftware/invenio-records-resources/blob/master/invenio_records_resources/config.py @@ -500,6 +500,79 @@ RDM_FACETS = { "field": "subjects.subject", }, }, + "publication_date": { + "facet": DateHistogramFacet( + field="metadata.publication_date_range", + label=_("Publication year"), + interval="year", + format="yyyy", + ), + "ui": {"field": "publication_date"}, + }, + "affiliations": { + "facet": TermsFacet( + field="metadata.creators.affiliations.id", + label=_("Author affiliations"), + value_labels=AffiliationsLabels("affiliations"), + ), + "ui": { + "field": "metadata.creators.affiliations", + }, + }, + "funders": { + "facet": TermsFacet( + field="metadata.funding.funder.id", + label=_("Funders"), + value_labels=FundersLabels("funders"), + ), + "ui": { + "field": "metadata.funding.funder", + }, + }, + "author_identifiers": { + "facet": TermsFacet( + field="metadata.creators.person_or_org.identifiers.scheme", + label=_("Author identifiers"), + value_labels={"orcid": _("ORCID")}, + ), + "ui": { + "field": "metadata.creators.person_or_org.identifiers.scheme", + }, + }, + "rights": { + "facet": TermsFacet( + field="metadata.rights.id", + label=_("Licenses"), + value_labels=VocabularyLabels("licenses"), + ), + "ui": { + "field": "rights", + }, + }, + "relations": { + "facet": TermsFacet( + field="metadata.related_identifiers.relation_type.id", + label=_("Related works"), + value_labels=VocabularyLabels("relationtypes"), + ), + "ui": { + "field": "related_identifiers.relation_type", + }, + }, + "references": { + "facet": TermsFacet( + field="metadata.references.scheme", + label=_("References"), + value_labels={ + "doi": _("DOI"), + "url": _("URL"), + "": _("No identifier"), + }, + ), + "ui": { + "field": "metadata.references.scheme", + }, + }, } @@ -524,7 +597,18 @@ def word_communities(node): RDM_SEARCH = { # Supported values from RDM_FACETS - "facets": ["language", "subject"], + "facets": [ + "language", + "resource_type", + "publication_date", + "subject", + "funders", + "affiliations", + "author_identifiers", + "rights", + "relations", + "references", + ], # Supported values from RDM_SORT_OPTIONS "sort": [ "bestmatch", @@ -534,6 +618,7 @@ RDM_SEARCH = { "updated-asc", "created-desc", "created-asc", + "mostviewed", ], "query_parser_cls": QueryParser.factory( mapping={ @@ -541,6 +626,11 @@ RDM_SEARCH = { "title": "metadata.title", "subject": "metadata.subjects.subject", "contributor": "metadata.creators.person_or_org.name", + "affiliation": "metadata.creators.affiliations.name", + "funder": "metadata.funding.funder.name", + "references": FieldValueMapper( + "metadata.references.identifier", word=word_doi + ), # taken from Zenodo "doi": FieldValueMapper("pids.doi.identifier", word=word_doi), "communities": FieldValueMapper( @@ -550,8 +640,6 @@ RDM_SEARCH = { "orcid": "metadata.creators.person_or_org.identifiers.identifier", "ror": "metadata.creators.affiliations.id", "issn": "custom_fields.journal\:journal.issn", - # Specific to InveniRDM Starter - "content": "custom_fields.rs\:content_text", }, tree_transformer_cls=SearchFieldTransformer, ), @@ -561,7 +649,19 @@ COMMUNITIES_RECORDS_SEARCH = deepcopy(RDM_SEARCH) """Communities record search config is the same as the main record search.""" RDM_SEARCH_DRAFTS = { - "facets": ["is_published", "language", "subject"], + "facets": [ + "is_published", + "language", + "resource_type", + "publication_date", + "subject", + "funders", + "affiliations", + "author_identifiers", + "rights", + "relations", + "references", + ], "sort": [ "bestmatch", "newest", @@ -570,6 +670,7 @@ RDM_SEARCH_DRAFTS = { "updated-asc", "created-desc", "created-asc", + "mostviewed", ], } """User records search configuration (i.e. list of uploads)."""