Skip to content

Commit

Permalink
datacite: fix funding serialization for optional award fields
Browse files Browse the repository at this point in the history
* Makes sure that we handle missing values for optional award fields
  like "title" and "number".
  • Loading branch information
slint committed Dec 5, 2024
1 parent 731ac68 commit e175a31
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions invenio_rdm_records/resources/serializers/datacite/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
from flask_resources.serializers import BaseSerializerSchema
from invenio_access.permissions import system_identity
from invenio_i18n import lazy_gettext as _
from invenio_records_resources.proxies import current_service_registry
from marshmallow import Schema, ValidationError, fields, missing, post_dump, validate
from marshmallow_utils.fields import SanitizedUnicode
from marshmallow_utils.html import strip_html
Expand Down Expand Up @@ -617,8 +616,12 @@ def get_funding(self, obj):
# award
award = funding.get("award")
if award: # having an award is optional
funding_ref["awardTitle"] = award.get("title", {}).get("en", missing)
funding_ref["awardNumber"] = award["number"]
award_title = award.get("title", {}).get("en")
if award_title:
funding_ref["awardTitle"] = award_title
award_number = award.get("number")
if award_number:
funding_ref["awardNumber"] = award_number

identifiers = award.get("identifiers", [])
if identifiers:
Expand Down

0 comments on commit e175a31

Please sign in to comment.