From 736c6bdacc06e9ed2f9fff93a157920b66d2b887 Mon Sep 17 00:00:00 2001 From: Viktor Bozhinov Date: Thu, 10 Feb 2022 16:08:11 +0000 Subject: [PATCH] fix: use alternative ICAT mapping for Document pid when doi is None #314 --- datagateway_api/src/search_api/models.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/datagateway_api/src/search_api/models.py b/datagateway_api/src/search_api/models.py index 66fc44c1..c1e13ee3 100644 --- a/datagateway_api/src/search_api/models.py +++ b/datagateway_api/src/search_api/models.py @@ -236,6 +236,10 @@ class Document(PaNOSCAttribute): members: Optional[List["Member"]] = [] parameters: Optional[List["Parameter"]] = [] + @validator("pid", pre=True, always=True) + def set_pid(cls, value): # noqa: B902, N805 + return f"pid:{value}" if isinstance(value, int) else value + @validator("is_public", pre=True, always=True) def set_is_public(cls, value): # noqa: B902, N805 if not value: