From 628b242fc99f9690391b8824571034418e84aa24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Katja=20Su=CC=88ss?= Date: Sat, 25 Mar 2023 16:59:26 +0100 Subject: [PATCH 1/2] Add UID to relationvalue_converter summary Support RelationList field with named StaticCatalogVocabulary and SelectWidget --- news/1605.feature | 1 + src/plone/restapi/serializer/relationfield.py | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 news/1605.feature diff --git a/news/1605.feature b/news/1605.feature new file mode 100644 index 0000000000..b005cd7931 --- /dev/null +++ b/news/1605.feature @@ -0,0 +1 @@ +Add UID to relationvalue_converter summary. @ksuess \ No newline at end of file diff --git a/src/plone/restapi/serializer/relationfield.py b/src/plone/restapi/serializer/relationfield.py index 931453fbea..28483ce424 100644 --- a/src/plone/restapi/serializer/relationfield.py +++ b/src/plone/restapi/serializer/relationfield.py @@ -18,9 +18,9 @@ @implementer(IJsonCompatible) def relationvalue_converter(value): if value.to_object: - summary = getMultiAdapter( - (value.to_object, getRequest()), ISerializeToJsonSummary - )() + request = getRequest() + request.form["metadata_fields"] = ["UID"] + summary = getMultiAdapter((value.to_object, request), ISerializeToJsonSummary)() return json_compatible(summary) From 29c42ba7373555fecf33d4fdc2783b3336ae2bd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Katja=20Su=CC=88ss?= Date: Sat, 25 Mar 2023 17:31:38 +0100 Subject: [PATCH 2/2] Fix tests: UID --- src/plone/restapi/tests/test_content_get.py | 2 ++ src/plone/restapi/tests/test_dxfield_serializer.py | 3 +++ src/plone/restapi/tests/test_serializer_converters.py | 1 + 3 files changed, 6 insertions(+) diff --git a/src/plone/restapi/tests/test_content_get.py b/src/plone/restapi/tests/test_content_get.py index 0bd9e0cded..34cd70d137 100644 --- a/src/plone/restapi/tests/test_content_get.py +++ b/src/plone/restapi/tests/test_content_get.py @@ -128,6 +128,7 @@ def test_get_content_includes_related_items(self): { "@id": self.portal_url + "/folder1/folder2/doc2", "@type": "Document", + "UID": self.portal.folder1.folder2.doc2.UID(), "description": "", "review_state": "published", "title": "My Document 2", @@ -166,6 +167,7 @@ def test_get_content_related_items_without_workflow(self): { "@id": self.portal_url + "/imagewf", "@type": "Image", + "UID": self.portal.imagewf.UID(), "description": "This is an image", "review_state": None, "title": "Image without workflow", diff --git a/src/plone/restapi/tests/test_dxfield_serializer.py b/src/plone/restapi/tests/test_dxfield_serializer.py index 6c386ece68..851d48cdd2 100644 --- a/src/plone/restapi/tests/test_dxfield_serializer.py +++ b/src/plone/restapi/tests/test_dxfield_serializer.py @@ -273,6 +273,7 @@ def test_relationchoice_field_serialization_returns_summary_dict(self): { "@id": "http://nohost/plone/doc2", "@type": "DXTestDocument", + "UID": doc2.UID(), "title": "Referenceable Document", "description": "Description 2", "review_state": "private", @@ -304,6 +305,7 @@ def test_relationlist_field_serialization_returns_list(self): { "@id": "http://nohost/plone/doc2", "@type": "DXTestDocument", + "UID": doc2.UID(), "title": "Referenceable Document", "description": "Description 2", "review_state": "private", @@ -311,6 +313,7 @@ def test_relationlist_field_serialization_returns_list(self): { "@id": "http://nohost/plone/doc3", "@type": "DXTestDocument", + "UID": doc3.UID(), "title": "Referenceable Document", "description": "Description 3", "review_state": "private", diff --git a/src/plone/restapi/tests/test_serializer_converters.py b/src/plone/restapi/tests/test_serializer_converters.py index c3f7d83838..6f9c1cf304 100644 --- a/src/plone/restapi/tests/test_serializer_converters.py +++ b/src/plone/restapi/tests/test_serializer_converters.py @@ -203,6 +203,7 @@ def test_relation_value(self): "@id": "http://nohost/plone/doc1", "@type": "DXTestDocument", "title": "Document 1", + "UID": doc1.UID(), "description": "Description", "review_state": "private", },