From 3de4e6b603a5f2c5a74820ce1cdd173ea30a6930 Mon Sep 17 00:00:00 2001 From: Alzpetka Date: Mon, 7 Oct 2024 13:48:36 +0200 Subject: [PATCH] check if doi already associated when automatic mode --- oarepo_doi/api.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/oarepo_doi/api.py b/oarepo_doi/api.py index 5bbfd11..464fd78 100644 --- a/oarepo_doi/api.py +++ b/oarepo_doi/api.py @@ -17,6 +17,11 @@ def create_doi(service, record, data, event=None): """if event = None, doi will be created as a draft.""" mapping = obj_or_import_string(service.mapping[record.schema])() + doi_value = mapping.get_doi(record) + if doi_value: + raise ValidationError( + message="DOI already associated with the record." + ) errors = mapping.metadata_check(record) record_service = get_record_service_for_record(record) record["links"] = record_service.links_item_tpl.expand(system_identity, record)