Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add UID to relationvalue_converter summary #1605

Merged
merged 3 commits into from
Apr 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ksuess we use [ksuess] in backend packages. :) Just FYI. I will fix this for you.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tisto We just decided to switch to using @githubusername everywhere, for consistency. plone/documentation#1478 (comment)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a bonus, GitHub renders @username format to a clickable username.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@davisagli ok, that's new for me. Awesome! That makes lots of sense to me. Will stick to this from now on for plone.rest(api) releases.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ksuess sorry, for the noise. Turns out you were right and I was wrong. :)

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