Skip to content

Commit

Permalink
Add UID to relationvalue_converter summary (#1605)
Browse files Browse the repository at this point in the history
* Add UID to relationvalue_converter summary

Support RelationList field with named StaticCatalogVocabulary and SelectWidget

* Fix tests: UID

---------

Co-authored-by: Timo Stollenwerk <tisto@users.noreply.github.com>
  • Loading branch information
ksuess and tisto authored Apr 7, 2023
1 parent 9241e72 commit c39ca4d
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions news/1605.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add UID to relationvalue_converter summary. @ksuess
6 changes: 3 additions & 3 deletions src/plone/restapi/serializer/relationfield.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
2 changes: 2 additions & 0 deletions src/plone/restapi/tests/test_content_get.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
3 changes: 3 additions & 0 deletions src/plone/restapi/tests/test_dxfield_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -304,13 +305,15 @@ 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",
},
{
"@id": "http://nohost/plone/doc3",
"@type": "DXTestDocument",
"UID": doc3.UID(),
"title": "Referenceable Document",
"description": "Description 3",
"review_state": "private",
Expand Down
1 change: 1 addition & 0 deletions src/plone/restapi/tests/test_serializer_converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
Expand Down

0 comments on commit c39ca4d

Please sign in to comment.