Skip to content

Commit

Permalink
legacy: REST API legacy fixes
Browse files Browse the repository at this point in the history
* Fixes issue with legacy API where it was allowed to sent a FP7
  project identifier as a single number.

* Fixes issue with legacy API where a single alternate identifier was
  not correctly handled.
  • Loading branch information
lnielsen committed Sep 18, 2023
1 parent 1918996 commit 5a3a565
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
10 changes: 10 additions & 0 deletions site/zenodo_rdm/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,3 +331,13 @@ def lock_edit_record_published_files(record):

RDM_LOCK_EDIT_PUBLISHED_FILES = lock_edit_record_published_files
"""Lock editing already published files (enforce record versioning)."""

APP_RDM_RECORD_THUMBNAIL_SIZES = [
"10",
"50",
"100",
"250",
"750",
"1200",
]
"""Thumbnail sizes."""
13 changes: 10 additions & 3 deletions site/zenodo_rdm/legacy/deserializers/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,14 @@ def split_identifiers(self, data, **kwargs):
else:
related_identifiers.append(identifier)

if related_identifiers:
data["related_identifiers"] = related_identifiers
# A single alternate identifier will need ot set
if input_identifiers:
if related_identifiers:
data["related_identifiers"] = related_identifiers
else:
data.pop("related_identifiers")
if alternate_identifiers:
data["alternate_identifiers"] = alternate_identifiers

return data

title = SanitizedUnicode()
Expand Down Expand Up @@ -182,6 +185,10 @@ def load_funding(self, obj):
return missing

for grant in grants:
# FP7 project grant - special case for FP7 project grant
if not "::" in grant["id"]:
grant["id"] = "10.13039/501100000780::{0}".format(grant["id"])

# format "10.13039/501100000780::190101904"
id_parts = grant["id"].split("::", 1)
assert len(id_parts) == 2
Expand Down

0 comments on commit 5a3a565

Please sign in to comment.