From 82c1e445d8762455b2f4940f1fd68e41f7ed8f0e Mon Sep 17 00:00:00 2001 From: Mohammed Taha Khan Date: Fri, 27 Mar 2026 11:37:28 +0100 Subject: [PATCH] fix: add CERN DOI prefix metadata check --- scripts/metadata_checks.py | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/scripts/metadata_checks.py b/scripts/metadata_checks.py index a6b8ca15..96321b94 100644 --- a/scripts/metadata_checks.py +++ b/scripts/metadata_checks.py @@ -20,6 +20,7 @@ from invenio_communities.proxies import current_communities from invenio_db import db from werkzeug.local import LocalProxy +from flask import current_app community_service = LocalProxy(lambda: current_communities.service) @@ -50,10 +51,43 @@ } ], }, + { + "id": "cern:doi/prefix-community", + "title": "CERN DOI prefix required", + "message": "Records with publisher CERN must use the CERN DOI prefix.", + "description": "Ensures records published by CERN use the configured DataCite prefix when a DOI is provided.", + "level": "error", + "error_path": "pids.doi", + "condition": { + "type": "logical", + "operator": "and", + "expressions": [ + { + "type": "comparison", + "left": {"type": "field", "path": "metadata.publisher"}, + "operator": "==", + "right": "CERN", + }, + { + "type": "comparison", + "left": {"type": "field", "path": "pids.doi.identifier"}, + "operator": "!=", + "right": "", + }, + ], + }, + "checks": [ + { + "type": "comparison", + "left": {"type": "field", "path": "pids.doi.identifier"}, + "operator": "^=", + "right": current_app.config["DATACITE_PREFIX"], + } + ], + }, ] } -from flask import current_app CDS_CERN_SCIENTIFIC_COMMUNITY_ID = current_app.config[ "CDS_CERN_SCIENTIFIC_COMMUNITY_ID"