diff --git a/oarepo_doi/api.py b/oarepo_doi/api.py index 7534acd..5bbfd11 100644 --- a/oarepo_doi/api.py +++ b/oarepo_doi/api.py @@ -66,10 +66,9 @@ def edit_doi(service, record, event=None): mapping = obj_or_import_string(service.mapping[record.schema])() doi_value = mapping.get_doi(record) - + if not check_if_correct_doi(doi_value, record): + return if doi_value: - if not check_if_correct_doi(doi_value, record): - return errors = mapping.metadata_check(record) record_service = get_record_service_for_record(record) record["links"] = record_service.links_item_tpl.expand(system_identity, record) @@ -105,6 +104,10 @@ def edit_doi(service, record, event=None): def check_if_correct_doi(value, record): try: doi = PersistentIdentifier.get_by_object('doi', "rec", record.id) #object has no doi in database == doi was added via created form by user + if doi and not value: #doi deleted by user + raise ValidationError( + message="Datacite doi deleted by the user." + ) except PIDDoesNotExistError as e: return False try: