diff --git a/news/1939.bugfix b/news/1939.bugfix new file mode 100644 index 000000000..c14671a5a --- /dev/null +++ b/news/1939.bugfix @@ -0,0 +1 @@ +Serialize the `layout` of a Plone Site if it is a Plone 6 site. @erral diff --git a/src/plone/restapi/serializer/site.py b/src/plone/restapi/serializer/site.py index c913bead7..8bc845d15 100644 --- a/src/plone/restapi/serializer/site.py +++ b/src/plone/restapi/serializer/site.py @@ -65,6 +65,8 @@ def __call__(self, version=None, include_items=True, include_expansion=True): if HAS_PLONE_6: result["UID"] = self.context.UID() + result["layout"] = self.context.getLayout() + # Insert review_state wf = getToolByName(self.context, "portal_workflow") result["review_state"] = wf.getInfoFor( 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 22b93076d..bbea34358 100644 --- a/src/plone/restapi/tests/http-examples/jwt_logged_in.resp +++ b/src/plone/restapi/tests/http-examples/jwt_logged_in.resp @@ -57,6 +57,7 @@ Content-Type: application/json "title": "English", "token": "en" }, + "layout": "document_view", "lock": { "locked": false, "stealable": true diff --git a/src/plone/restapi/tests/http-examples/navroot_site_get.resp b/src/plone/restapi/tests/http-examples/navroot_site_get.resp index 3865a034b..08450ba49 100644 --- a/src/plone/restapi/tests/http-examples/navroot_site_get.resp +++ b/src/plone/restapi/tests/http-examples/navroot_site_get.resp @@ -22,6 +22,7 @@ Content-Type: application/json "title": "English", "token": "en" }, + "layout": "language-switcher", "lock": { "locked": false, "stealable": true diff --git a/src/plone/restapi/tests/http-examples/navroot_standard_site_content_get.resp b/src/plone/restapi/tests/http-examples/navroot_standard_site_content_get.resp index 013b20536..878fa2e52 100644 --- a/src/plone/restapi/tests/http-examples/navroot_standard_site_content_get.resp +++ b/src/plone/restapi/tests/http-examples/navroot_standard_site_content_get.resp @@ -22,6 +22,7 @@ Content-Type: application/json "title": "English", "token": "en" }, + "layout": "document_view", "lock": { "locked": false, "stealable": true diff --git a/src/plone/restapi/tests/http-examples/navroot_standard_site_content_get_expansion.resp b/src/plone/restapi/tests/http-examples/navroot_standard_site_content_get_expansion.resp index 9c4b14dfa..ab3020d20 100644 --- a/src/plone/restapi/tests/http-examples/navroot_standard_site_content_get_expansion.resp +++ b/src/plone/restapi/tests/http-examples/navroot_standard_site_content_get_expansion.resp @@ -39,6 +39,7 @@ Content-Type: application/json "title": "English", "token": "en" }, + "layout": "document_view", "lock": { "locked": false, "stealable": true diff --git a/src/plone/restapi/tests/http-examples/navroot_standard_site_get.resp b/src/plone/restapi/tests/http-examples/navroot_standard_site_get.resp index 3865a034b..efe346c4a 100644 --- a/src/plone/restapi/tests/http-examples/navroot_standard_site_get.resp +++ b/src/plone/restapi/tests/http-examples/navroot_standard_site_get.resp @@ -22,6 +22,7 @@ Content-Type: application/json "title": "English", "token": "en" }, + "layout": "document_view", "lock": { "locked": false, "stealable": true diff --git a/src/plone/restapi/tests/http-examples/navroot_standard_site_get_expansion.resp b/src/plone/restapi/tests/http-examples/navroot_standard_site_get_expansion.resp index 69129b661..d0cd65380 100644 --- a/src/plone/restapi/tests/http-examples/navroot_standard_site_get_expansion.resp +++ b/src/plone/restapi/tests/http-examples/navroot_standard_site_get_expansion.resp @@ -39,6 +39,7 @@ Content-Type: application/json "title": "English", "token": "en" }, + "layout": "document_view", "lock": { "locked": false, "stealable": true @@ -92,6 +93,7 @@ Content-Type: application/json "title": "English", "token": "en" }, + "layout": "document_view", "lock": { "locked": false, "stealable": true diff --git a/src/plone/restapi/tests/http-examples/site_get_expand_navroot.resp b/src/plone/restapi/tests/http-examples/site_get_expand_navroot.resp index 8f20f6ad1..12b4348ae 100644 --- a/src/plone/restapi/tests/http-examples/site_get_expand_navroot.resp +++ b/src/plone/restapi/tests/http-examples/site_get_expand_navroot.resp @@ -39,6 +39,7 @@ Content-Type: application/json "title": "English", "token": "en" }, + "layout": "language-switcher", "lock": { "locked": false, "stealable": true @@ -116,6 +117,7 @@ Content-Type: application/json "title": "English", "token": "en" }, + "layout": "language-switcher", "lock": { "locked": false, "stealable": true diff --git a/src/plone/restapi/tests/http-examples/siteroot.resp b/src/plone/restapi/tests/http-examples/siteroot.resp index 22b93076d..bbea34358 100644 --- a/src/plone/restapi/tests/http-examples/siteroot.resp +++ b/src/plone/restapi/tests/http-examples/siteroot.resp @@ -57,6 +57,7 @@ Content-Type: application/json "title": "English", "token": "en" }, + "layout": "document_view", "lock": { "locked": false, "stealable": true diff --git a/src/plone/restapi/tests/test_dxcontent_serializer.py b/src/plone/restapi/tests/test_dxcontent_serializer.py index c41e6a3c0..ebbdeda1c 100644 --- a/src/plone/restapi/tests/test_dxcontent_serializer.py +++ b/src/plone/restapi/tests/test_dxcontent_serializer.py @@ -796,6 +796,13 @@ def test_allow_discussion_global_enabled_but_instance_has_no_discussion_behavior self.assertIn("allow_discussion", obj) self.assertEqual(False, obj["allow_discussion"]) + @unittest.skipUnless(HAS_PLONE_6, "Requires Dexterity-based site root") + def test_get_layout_for_siteroot(self): + current_layout = self.portal.getLayout() + obj = self.serialize(self.portal) + self.assertIn("layout", obj) + self.assertEqual(current_layout, obj["layout"]) + class TestDXContentPrimaryFieldTargetUrl(unittest.TestCase): layer = PLONE_RESTAPI_DX_INTEGRATION_TESTING