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
5 changes: 5 additions & 0 deletions invenio.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,11 @@ RDM_RECORDS_RELATED_IDENTIFIERS_SCHEMES = {
"validator": schemes.is_indico,
"datacite": "INDICO"
},
"edms": {
"label": _("EDMS"),
"validator": schemes.is_edms,
"datacite": "EDMS"
},
"hal": {
"label": "HAL",
"validator": schemes.is_hal,
Expand Down
26 changes: 22 additions & 4 deletions site/cds_rdm/schemes.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
cds_rdm_regexp = re.compile(r"[a-z0-9]{5}-[a-z0-9]{5}", flags=re.I)
legacy_cds_pattern = re.compile(r"^\d+$", flags=re.I)
is_indico_regexp = re.compile(r"^[a-zA-Z0-9]+$", flags=re.I)
inis_pattern = re.compile(r'^(?:\d+|RN:\d+)$', flags=re.I)
inis_pattern = re.compile(r"^(?:\d+|RN:\d+)$", flags=re.I)
edms_pattern = re.compile(r"^\d+$", flags=re.I)


def is_aleph(val):
"""Test if argument is an Aleph ID.
Expand Down Expand Up @@ -55,7 +57,6 @@ def is_inis(val):
return inis_pattern.match(val)



def inis():
"""Define validator for `custom_scheme`."""
return {
Expand All @@ -64,7 +65,6 @@ def inis():
}



def is_inspire(val):
"""Test if argument is an Inspire ID.

Expand All @@ -88,6 +88,25 @@ def is_indico(val):
return str(val).isdigit()


def is_edms(val):
"""Test if argument is an EDMS document number."""
return edms_pattern.match(str(val))


def generate_edms_url(scheme, value):
"""Generate EDMS url."""
return f"https://edms.cern.ch/document/{value}"


def edms():
"""Define scheme for EDMS links."""
return {
"validator": is_edms,
"normalizer": lambda value: str(value),
"url_generator": generate_edms_url,
}


def indico():
"""Define scheme for Indico Links."""
return {
Expand All @@ -106,7 +125,6 @@ def inspire():
}



def inspire_author():
"""Define validator for Inspire author."""
return {
Expand Down
1 change: 1 addition & 0 deletions site/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ inspire = "cds_rdm.schemes:inspire"
inspire_author = "cds_rdm.schemes:inspire_author"
cds = "cds_rdm.schemes:cds"
indico = "cds_rdm.schemes:indico"
edms = "cds_rdm.schemes:edms"

[project.entry-points."invenio_db.alembic"]
cds_rdm = "cds_rdm:alembic"
Expand Down
5 changes: 5 additions & 0 deletions site/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,11 @@ def app_config(app_config, mock_datacite_client):
"validator": schemes.is_indico,
"datacite": "INDICO",
},
"edms": {
"label": _("EDMS"),
"validator": schemes.is_edms,
"datacite": "EDMS",
},
}
app_config["LOGGING_CONSOLE_LEVEL"] = "INFO"
app_config["JOBS_LOGGING_LEVEL"] = "INFO"
Expand Down
Loading