Skip to content
Open
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
23 changes: 0 additions & 23 deletions datasets/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,28 +116,6 @@ def update(self, identity, id_, data, *args, revision_id=None, **kwargs):
identity, id_, data, *args, revision_id=revision_id, **kwargs
)


class OverriddenRouteResourceConfigMixin:
@property
def routes(self):
"""Override routes to use path instead of default converter for pid_value.

This was causing a problem when PID contained slashes (doi:1234/zenodo.12345 for example).
It would parse only first part before the slash.
"""
routes = super().routes

updated_routes = {}
for (
key,
route,
) in routes.items():
updated_route = route.replace("<pid_value>", "<path:pid_value>")
updated_routes[key] = updated_route

return updated_routes


COPY_TO_MAPPINGS = [
# boost_10 - Primary identifiers (highest weight)
("metadata.title", 10),
Expand Down Expand Up @@ -243,7 +221,6 @@ def routes(self):
PrependMixin("PIDFieldContext", ExternalPIDFieldContextMixin),
PrependMixin("Draft", PIDStatusCheckFieldMixin),
PrependMixin("RecordService", UpdatableRecordServiceMixin),
PrependMixin("RecordResourceConfig", OverriddenRouteResourceConfigMixin),
AddFacetGroup(
"default",
[
Expand Down
311 changes: 15 additions & 296 deletions invenio.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@ from oarepo import config

# glitchtip for reporting incidents
config.initialize_glitchtip()

# i18n
config.initialize_i18n()

config.configure_generic_parameters(
languages=(("cs", _("Czech")),),
languages=(("cs", _("Czech")),), use_path_pid_ids=True
)

config.configure_ui(
code="nmd",
name=_("National Metadata Directory"),
Expand All @@ -24,22 +22,7 @@ config.configure_ui(
),
support_contact="info@eosc.cz",
)
THEME_LOGO = "images/theme-logo.png"

# config.configure_communities(
# # if you have different community roles than owner, curator and member,
# # you can specify them here
# )

# config.register_workflow(
# "default",
# _("Default deposition workflow"),
# "common.workflows.default.DefaultWorkflowPermissions",
# "common.workflows.default.DefaultWorkflowRequests",
# )

config.configure_stats()

config.configure_cron(
check_record_availability={
"task": "riv.tasks.check_availability.check_availability_task",
Expand All @@ -59,88 +42,20 @@ config.configure_cron(
},
)

# to enable datacite, uncomment the following lines
# from common.config.datacite import (
# enable_datacite,
# datacite_default_credentials,
# datacite_community_prefix
# )
# enable_datacite(env)
# datacite_default_credentials(
# env.INVENIO_DATACITE_PREFIX,
# env.INVENIO_DATACITE_USERNAME,
# env.INVENIO_DATACITE_PASSWORD)
# )
# datacite_community_prefix(
# "biocev",
# env.INVENIO_DATACITE_BIOCEV_PREFIX,
# env.INVENIO_DATACITE_BIOCEV_USERNAME,
# env.INVENIO_DATACITE_BIOCEV_PASSWORD)

# vocabularies:
# config.configure_vocabulary(
# code="languages",
# name=_("Languages"),
# description=_("Language definitions vocabulary."),
# props={
# "alpha3Code": {
# "description": _("ISO 639-2 standard 3-letter language code"),
# "icon": None,
# "label": _("Alpha3 code (English)"),
# "multiple": False,
# "placeholder": "eng, cze...",
# "search": False,
# },
# },
# dump_options=True,
# )

# Feel free to add/override configuration options here. List of options can be
# found in the Invenio source code:
# https://github.com/inveniosoftware/invenio-app-rdm/blob/master/invenio_app_rdm/config.py


WEBPACKEXT_NPM_PKG_CLS = "pynpm:PNPMPackage"
# datasets model registration
# nasty hack to get it owrking on osx 26
import os
config.configure_datastreams(readers={"catch-all": "datasets.oai.catchall.CatchAllReader",
"zenodo": "datasets.oai.zenodo.ZenodoReader"},
transformers={"catch-all": "datasets.oai.catchall.CatchAllTransformer",
"zenodo": "datasets.oai.zenodo.ZenodoTransformer",
"lindat": "datasets.oai.lindat.LindatTransformer",
"id-from-doi": "datasets.oai.avcr.IdFromDOITransformer"}
)

from datasets import datasets_model

os.environ["DYLD_FALLBACK_LIBRARY_PATH"] = "/opt/homebrew/lib"

datasets_model.register()
DASHBOARD_RECORD_CREATE_URL = "/datasets/uploads/new"

# einfra oidc
# TODO: move to config.configure_einfra_oidc(env) function and check for all needed variables
env = config.load_configuration_variables()
if os.environ.get("INVENIO_REMOTE_AUTH_ENABLED", "no").lower() in ("true", "yes", "1"):
from oarepo_oidc_einfra import EINFRA_LOGIN_APP

OAUTHCLIENT_REMOTE_APPS = {"e-infra": EINFRA_LOGIN_APP}
# needed for disconnect
from oarepo_oidc_einfra import config as oarepo_einfra_config

EINFRA = dict(
consumer_key=env.INVENIO_EINFRA_CONSUMER_KEY,
consumer_secret=env.INVENIO_EINFRA_CONSUMER_SECRET,
**{
k[len("EINFRA_") :].lower(): getattr(oarepo_einfra_config, k)
for k in dir(oarepo_einfra_config)
if k.startswith("EINFRA_")
},
)
else:
OAUTHCLIENT_REMOTE_APPS = {}

from invenio_notifications.backends.email import EmailNotificationBackend

NOTIFICATION_BACKENDS = {"email": EmailNotificationBackend}

# Communities not supported in this release
COMMUNITIES_REGISTER_UI_BLUEPRINT = False
config.configure_einfra_oidc()
config.configure_jobs()

from ui.datasets import search_redirect
APP_RDM_DETAIL_SIDE_BAR_TEMPLATES = [
"manage_menu.html",
"invenio_app_rdm/records/details/side_bar/external_resources.html",
Expand All @@ -151,210 +66,14 @@ APP_RDM_DETAIL_SIDE_BAR_TEMPLATES = [
"oarepo_ui/record_detail/side_bar/export.html",
"invenio_app_rdm/records/details/side_bar/technical_metadata.html",
]
"""Template names for detail view sidebar components"""

RDM_CITATION_STYLES = [
# TODO: implement or remove from here
("datacite", _("DataCite")),
]

RDM_CITATION_STYLES_DEFAULT = "datacite"

from invenio_rdm_records.resources.config import (
RDMGrantGroupAccessResourceConfig,
RDMGrantUserAccessResourceConfig,
RDMParentGrantsResourceConfig,
RDMParentRecordLinksResourceConfig,
RDMRecordResourceConfig,
)

RDMRecordResourceConfig.routes["record-access-request"] = (
"/<path:pid_value>/access/request"
)
RDMRecordResourceConfig.routes["access-request-settings"] = "/<path:pid_value>/access"
RDMParentRecordLinksResourceConfig.url_prefix = "/records/<path:pid_value>/access"
RDMParentGrantsResourceConfig.url_prefix = "/records/<path:pid_value>/access"
RDMGrantUserAccessResourceConfig.url_prefix = "/records/<path:pid_value>/access"
RDMGrantGroupAccessResourceConfig.url_prefix = "/records/<path:pid_value>/access"

from oarepo_rdm.resources.records.config import OARepoRDMRecordResourceConfig
from datasets.model import OverriddenRouteResourceConfigMixin
RDM_RECORDS_RESOURCE_CONFIG_CLASS = type("DatasetsRecordsResourceConfig",
(OverriddenRouteResourceConfigMixin, OARepoRDMRecordResourceConfig), {})


from invenio_app_rdm import config as rdm_config

from datasets.oai.avcr import IdFromDOITransformer
from datasets.oai.catchall import CatchAllReader, CatchAllTransformer
from datasets.oai.lindat import LindatTransformer
from datasets.oai.zenodo import ZenodoReader, ZenodoTransformer

VOCABULARIES_DATASTREAM_READERS = {
**rdm_config.VOCABULARIES_DATASTREAM_READERS,
"catch-all": CatchAllReader,
"zenodo": ZenodoReader,
}

VOCABULARIES_DATASTREAM_TRANSFORMERS = {
**rdm_config.VOCABULARIES_DATASTREAM_TRANSFORMERS,
"catch-all": CatchAllTransformer,
"zenodo": ZenodoTransformer,
"lindat": LindatTransformer,
"id-from-doi": IdFromDOITransformer,
}

VOCABULARIES_DATASTREAM_WRITERS = {
**rdm_config.VOCABULARIES_DATASTREAM_WRITERS,
}
"""Data Streams writers."""


# TODO: move this to oarepo?
import idutils
from invenio_rdm_records.config import always_valid

RDM_RECORDS_PERSONORG_SCHEMES = {
"orcid": {"label": _("ORCID"), "validator": idutils.is_orcid, "datacite": "ORCID"},
"isni": {"label": _("ISNI"), "validator": idutils.is_isni, "datacite": "ISNI"},
"gnd": {"label": _("GND"), "validator": idutils.is_gnd, "datacite": "GND"},
"ror": {"label": _("ROR"), "validator": idutils.is_ror, "datacite": "ROR"},
"researcherid": {
"label": _("ResearcherID"),
"validator": always_valid,
"datacite": "ResearcherID",
},
"scopusid": {
"label": _("Scopus Author ID"),
"validator": always_valid,
"datacite": "Scopus Author ID",
},
# funders are given crossref DOI, so we need to enable it as well
"doi": {"label": _("DOI"), "validator": idutils.is_doi, "datacite": "DOI"},
}

RDM_RECORDS_IDENTIFIERS_SCHEMES = {
"ark": {"label": _("ARK"), "validator": idutils.is_ark, "datacite": "ARK"},
"arxiv": {"label": _("arXiv"), "validator": idutils.is_arxiv, "datacite": "arXiv"},
"ads": {
"label": _("Bibcode"),
"validator": idutils.is_ads,
"datacite": "bibcode",
},
"crossreffunderid": {
"label": _("Crossref Funder ID"),
"validator": always_valid,
"datacite": "Crossref Funder ID",
},
"doi": {"label": _("DOI"), "validator": idutils.is_doi, "datacite": "DOI"},
"ean13": {"label": _("EAN13"), "validator": idutils.is_ean13, "datacite": "EAN13"},
"eissn": {"label": _("EISSN"), "validator": idutils.is_issn, "datacite": "EISSN"},
"grid": {"label": _("GRID"), "validator": always_valid, "datacite": "GRID"},
"handle": {
"label": _("Handle"),
"validator": idutils.is_handle,
"datacite": "Handle",
},
"igsn": {"label": _("IGSN"), "validator": always_valid, "datacite": "IGSN"},
"isbn": {"label": _("ISBN"), "validator": idutils.is_isbn, "datacite": "ISBN"},
"isni": {"label": _("ISNI"), "validator": idutils.is_isni, "datacite": "ISNI"},
"issn": {"label": _("ISSN"), "validator": idutils.is_issn, "datacite": "ISSN"},
"istc": {"label": _("ISTC"), "validator": idutils.is_istc, "datacite": "ISTC"},
"lissn": {"label": _("LISSN"), "validator": idutils.is_issn, "datacite": "LISSN"},
"lsid": {"label": _("LSID"), "validator": idutils.is_lsid, "datacite": "LSID"},
"pmid": {"label": _("PMID"), "validator": idutils.is_pmid, "datacite": "PMID"},
"purl": {"label": _("PURL"), "validator": idutils.is_purl, "datacite": "PURL"},
"upc": {"label": _("UPC"), "validator": always_valid, "datacite": "UPC"},
"url": {"label": _("URL"), "validator": idutils.is_url, "datacite": "URL"},
"urn": {"label": _("URN"), "validator": idutils.is_urn, "datacite": "URN"},
"w3id": {"label": _("W3ID"), "validator": always_valid, "datacite": "w3id"},
"other": {"label": _("Other"), "validator": always_valid, "datacite": "Other"},
}
"""These are used for references, main, alternate and related identifiers."""


RDM_RECORDS_RELATED_IDENTIFIERS_SCHEMES = RDM_RECORDS_IDENTIFIERS_SCHEMES
"""This variable is used to separate related identifiers."""

RDM_RECORDS_LOCATION_SCHEMES = {
"wikidata": {"label": _("Wikidata"), "validator": always_valid},
"geonames": {"label": _("GeoNames"), "validator": always_valid},
}


DASHBOARD_RECORD_CREATE_URL = "/datasets/uploads/new"
THEME_FRONTPAGE_RECORDS_LIST_SEARCH_MORE_ENDPOINT = "/datasets"

from ui.datasets import search_redirect

THEME_SEARCH_ENDPOINT = "/datasets"
SEARCH_UI_SEARCH_VIEW = search_redirect

# activate traceback with variables
from traceback_with_variables import activate_by_import # noqa

# invenio-jobs configuration
from invenio_jobs.services.permissions import (
JobLogsPermissionPolicy as InvenioJobLogsPermissionPolicy,
)
from oarepo_oaipmh_harvester.permissions import AdministrationWithQueryFilter


class JobLogsPermissionPolicy(InvenioJobLogsPermissionPolicy):
"""Permission policy for job logs."""

can_read = [AdministrationWithQueryFilter()]


APP_LOGS_PERMISSION_POLICY = JobLogsPermissionPolicy
JOBS_LOGGING_LEVEL = "INFO"
OAUTHCLIENT_AUTO_REDIRECT_TO_EXTERNAL_LOGIN = False

THEME_SEARCH_ENDPOINT = "/datasets"


# do not allow users to change profile info, we take this from EINFRA
USERPROFILES_READ_ONLY = True

# ROR client id - not used for authentication, just to increase rate limits
ROR_CLIENT_ID = "3764CLXJ4R9GT9L496QSKU2G3ZWVF71A"

# UI configuration for identifier schemes - take it from RDM ?
APP_RDM_IDENTIFIER_SCHEMES_UI = {
"orcid": {
"url_prefix": "http://orcid.org/",
"icon": "images/orcid.svg",
"label": "ORCID",
},
"ror": {
"url_prefix": "https://ror.org/",
"icon": "images/ror-icon.svg",
"label": "ROR",
},
"gnd": {
"url_prefix": "http://d-nb.info/gnd/",
"icon": "images/gnd-icon.svg",
"label": "GND",
},
}

# citations

RDM_CITATION_STYLES = [
("iso690-author-date-cs", _("ČSN ISO 690")),
("apa", _("APA")),
("harvard-cite-them-right", _("Harvard")),
("modern-language-association", _("MLA")),
("vancouver", _("Vancouver")),
("chicago-fullnote-bibliography", _("Chicago")),
("ieee", _("IEEE")),
]
"""List of citation style """

RDM_CITATION_STYLES_DEFAULT = "iso690-author-date-cs"
"""Default citation style"""


RDM_PERMISSION_POLICY = datasets_model.PermissionPolicy

# notifications have to be configured here because nma isn't using oarepo-requests
from invenio_rdm_records.notifications.builders import GrantUserAccessNotificationBuilder
from invenio_records_resources.references.entity_resolvers.results import ServiceResultResolver
from datasets.records.resolvers import RecordByPIDServiceResultResolver
Expand All @@ -373,4 +92,4 @@ NOTIFICATIONS_ENTITY_RESOLVERS = [

NOTIFICATIONS_BACKENDS = {
EmailNotificationBackend.id: EmailNotificationBackend(),
}
}