Skip to content

Commit

Permalink
validation error
Browse files Browse the repository at this point in the history
  • Loading branch information
Alzpeta committed Sep 9, 2024
1 parent 33e8258 commit 0020170
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
11 changes: 7 additions & 4 deletions oarepo_doi/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
import uuid

import requests
from flask import current_app
from invenio_access.permissions import system_identity
from invenio_base.utils import obj_or_import_string
from invenio_communities import current_communities
from invenio_search.engine import dsl
from marshmallow.exceptions import ValidationError
from oarepo_runtime.datastreams.utils import get_record_service_for_record


Expand All @@ -19,8 +19,9 @@ def create_doi(service, record, data, event=None):
record["links"] = record_service.links_item_tpl.expand(system_identity, record)

if len(errors) > 0 and event:
return # todo: dois can not be published with missing mandatory values

raise ValidationError(
message=f"Could not assigned doi due to validation error: {errors} "
)
request_metadata = {"data": {"type": "dois", "attributes": {}}}

payload = mapping.create_datacite_payload(data)
Expand Down Expand Up @@ -59,7 +60,9 @@ def edit_doi(service, record, event=None):
record_service = get_record_service_for_record(record)
record["links"] = record_service.links_item_tpl.expand(system_identity, record)
if len(errors) > 0 and event:
return # todo: dois can not be published with missing mandatory values
raise ValidationError(
message=f"Could not assigned doi due to validation error: {errors} "
)

doi_value = mapping.get_doi(record)
if doi_value:
Expand Down
1 change: 0 additions & 1 deletion oarepo_doi/types/doi.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from flask import current_app
from invenio_base.utils import obj_or_import_string
from invenio_requests.customizations import RequestType
from marshmallow.exceptions import ValidationError
from oarepo_requests.types.generic import NonDuplicableOARepoRequestType
from oarepo_requests.types.ref_types import ModelRefTypes
Expand Down

0 comments on commit 0020170

Please sign in to comment.