Repository: plone/plone.restapi (language: python)

Issue:
Plone Site serialization does not return review_state
In Plone 6.0, the Plone Site is also a Dexterity content type and supports a workflow, so it should also return the current review_state


Discussion / hints:

Fix patch:
diff --git a/news/1574.bugfix b/news/1574.bugfix
new file mode 100644
index 0000000000..c322388c70
--- /dev/null
+++ b/news/1574.bugfix
@@ -0,0 +1,1 @@
+Fix Plone Site serialization not returning the review_state in Plone 6. [ericof]
diff --git a/src/plone/restapi/serializer/site.py b/src/plone/restapi/serializer/site.py
index 6a0f1018bd..e95c3ef21d 100644
--- a/src/plone/restapi/serializer/site.py
+++ b/src/plone/restapi/serializer/site.py
@@ -69,6 +69,12 @@ def __call__(self, version=None):
 
         if HAS_PLONE_6:
             result["UID"] = self.context.UID()
+            # Insert review_state
+            wf = getToolByName(self.context, "portal_workflow")
+            result["review_state"] = wf.getInfoFor(
+                ob=self.context, name="review_state", default=None
+            )
+
             # Insert Plone Site DX root field values
             for schema in iterSchemata(self.context):
                 read_permissions = mergedTaggedValueDict(schema, READ_PERMISSIONS_KEY)


Test patch:
diff --git a/src/plone/restapi/tests/http-examples/jwt_logged_in.resp b/src/plone/restapi/tests/http-examples/jwt_logged_in.resp
index 2517d9f349..5a6fbf4e3d 100644
--- a/src/plone/restapi/tests/http-examples/jwt_logged_in.resp
+++ b/src/plone/restapi/tests/http-examples/jwt_logged_in.resp
@@ -59,6 +59,7 @@ Content-Type: application/json
     },
     "parent": {},
     "relatedItems": [],
+    "review_state": null,
     "rights": "",
     "subjects": [],
     "table_of_contents": null,
diff --git a/src/plone/restapi/tests/http-examples/siteroot.resp b/src/plone/restapi/tests/http-examples/siteroot.resp
index 2517d9f349..5a6fbf4e3d 100644
--- a/src/plone/restapi/tests/http-examples/siteroot.resp
+++ b/src/plone/restapi/tests/http-examples/siteroot.resp
@@ -59,6 +59,7 @@ Content-Type: application/json
     },
     "parent": {},
     "relatedItems": [],
+    "review_state": null,
     "rights": "",
     "subjects": [],
     "table_of_contents": null,