Skip to content
Open
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/1947.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Site endpoint `site` is now expandable. @sneridagh
5 changes: 5 additions & 0 deletions src/plone/restapi/services/site/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
xmlns:zcml="http://namespaces.zope.org/zcml"
>

<adapter
factory=".get.Site"
name="site"
/>

<plone:service
method="GET"
factory=".get.SiteGet"
Expand Down
3 changes: 3 additions & 0 deletions src/plone/restapi/tests/http-examples/collection.resp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ Content-Type: application/json
"navroot": {
"@id": "http://localhost:55001/plone/collection/@navroot"
},
"site": {
"@id": "http://localhost:55001/plone/collection/@site"
},
"types": {
"@id": "http://localhost:55001/plone/collection/@types"
},
Expand Down
12 changes: 12 additions & 0 deletions src/plone/restapi/tests/http-examples/collection_fullobjects.resp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ Content-Type: application/json
"navroot": {
"@id": "http://localhost:55001/plone/collection/@navroot"
},
"site": {
"@id": "http://localhost:55001/plone/collection/@site"
},
"types": {
"@id": "http://localhost:55001/plone/collection/@types"
},
Expand Down Expand Up @@ -83,6 +86,9 @@ Content-Type: application/json
"navroot": {
"@id": "http://localhost:55001/plone/front-page/@navroot"
},
"site": {
"@id": "http://localhost:55001/plone/front-page/@site"
},
"types": {
"@id": "http://localhost:55001/plone/front-page/@types"
},
Expand Down Expand Up @@ -159,6 +165,9 @@ Content-Type: application/json
"navroot": {
"@id": "http://localhost:55001/plone/doc1/@navroot"
},
"site": {
"@id": "http://localhost:55001/plone/doc1/@site"
},
"types": {
"@id": "http://localhost:55001/plone/doc1/@types"
},
Expand Down Expand Up @@ -231,6 +240,9 @@ Content-Type: application/json
"navroot": {
"@id": "http://localhost:55001/plone/doc2/@navroot"
},
"site": {
"@id": "http://localhost:55001/plone/doc2/@site"
},
"types": {
"@id": "http://localhost:55001/plone/doc2/@types"
},
Expand Down
3 changes: 3 additions & 0 deletions src/plone/restapi/tests/http-examples/content_get.resp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ Content-Type: application/json
"navroot": {
"@id": "http://localhost:55001/plone/folder/my-document/@navroot"
},
"site": {
"@id": "http://localhost:55001/plone/folder/my-document/@site"
},
"types": {
"@id": "http://localhost:55001/plone/folder/my-document/@types"
},
Expand Down
3 changes: 3 additions & 0 deletions src/plone/restapi/tests/http-examples/content_get_folder.resp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ Content-Type: application/json
"navroot": {
"@id": "http://localhost:55001/plone/folder/@navroot"
},
"site": {
"@id": "http://localhost:55001/plone/folder/@site"
},
"types": {
"@id": "http://localhost:55001/plone/folder/@types"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ Content-Type: application/json
"navroot": {
"@id": "http://localhost:55001/plone/folder/my-document/@navroot"
},
"site": {
"@id": "http://localhost:55001/plone/folder/my-document/@site"
},
"types": {
"@id": "http://localhost:55001/plone/folder/my-document/@types"
},
Expand Down
3 changes: 3 additions & 0 deletions src/plone/restapi/tests/http-examples/content_post.resp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ Location: http://localhost:55001/plone/folder/my-document
"navroot": {
"@id": "http://localhost:55001/plone/folder/my-document/@navroot"
},
"site": {
"@id": "http://localhost:55001/plone/folder/my-document/@site"
},
"types": {
"@id": "http://localhost:55001/plone/folder/my-document/@types"
},
Expand Down
3 changes: 3 additions & 0 deletions src/plone/restapi/tests/http-examples/document.resp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ Content-Type: application/json
"navroot": {
"@id": "http://localhost:55001/plone/front-page/@navroot"
},
"site": {
"@id": "http://localhost:55001/plone/front-page/@site"
},
"types": {
"@id": "http://localhost:55001/plone/front-page/@types"
},
Expand Down
3 changes: 3 additions & 0 deletions src/plone/restapi/tests/http-examples/event.resp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ Content-Type: application/json
"navroot": {
"@id": "http://localhost:55001/plone/event/@navroot"
},
"site": {
"@id": "http://localhost:55001/plone/event/@site"
},
"types": {
"@id": "http://localhost:55001/plone/event/@types"
},
Expand Down
3 changes: 3 additions & 0 deletions src/plone/restapi/tests/http-examples/expansion.resp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ Content-Type: application/json
"navroot": {
"@id": "http://localhost:55001/plone/front-page/@navroot"
},
"site": {
"@id": "http://localhost:55001/plone/front-page/@site"
},
"types": {
"@id": "http://localhost:55001/plone/front-page/@types"
},
Expand Down
3 changes: 3 additions & 0 deletions src/plone/restapi/tests/http-examples/expansion_expanded.resp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ Content-Type: application/json
"navroot": {
"@id": "http://localhost:55001/plone/front-page/@navroot"
},
"site": {
"@id": "http://localhost:55001/plone/front-page/@site"
},
"types": {
"@id": "http://localhost:55001/plone/front-page/@types"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ Content-Type: application/json
"navroot": {
"@id": "http://localhost:55001/plone/front-page/@navroot"
},
"site": {
"@id": "http://localhost:55001/plone/front-page/@site"
},
"types": [
{
"@id": "http://localhost:55001/plone/@types/Collection",
Expand Down
3 changes: 3 additions & 0 deletions src/plone/restapi/tests/http-examples/file.resp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ Content-Type: application/json
"navroot": {
"@id": "http://localhost:55001/plone/file/@navroot"
},
"site": {
"@id": "http://localhost:55001/plone/file/@site"
},
"types": {
"@id": "http://localhost:55001/plone/file/@types"
},
Expand Down
3 changes: 3 additions & 0 deletions src/plone/restapi/tests/http-examples/folder.resp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ Content-Type: application/json
"navroot": {
"@id": "http://localhost:55001/plone/folder/@navroot"
},
"site": {
"@id": "http://localhost:55001/plone/folder/@site"
},
"types": {
"@id": "http://localhost:55001/plone/folder/@types"
},
Expand Down
3 changes: 3 additions & 0 deletions src/plone/restapi/tests/http-examples/image.resp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ Content-Type: application/json
"navroot": {
"@id": "http://localhost:55001/plone/image/@navroot"
},
"site": {
"@id": "http://localhost:55001/plone/image/@site"
},
"types": {
"@id": "http://localhost:55001/plone/image/@types"
},
Expand Down
3 changes: 3 additions & 0 deletions src/plone/restapi/tests/http-examples/inherit_expansion.resp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ Content-Type: application/json
"navroot": {
"@id": "http://localhost:55001/plone/document/@navroot"
},
"site": {
"@id": "http://localhost:55001/plone/document/@site"
},
"types": {
"@id": "http://localhost:55001/plone/document/@types"
},
Expand Down
3 changes: 3 additions & 0 deletions src/plone/restapi/tests/http-examples/jwt_logged_in.resp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ Content-Type: application/json
"navroot": {
"@id": "http://localhost:55001/plone/@navroot"
},
"site": {
"@id": "http://localhost:55001/plone/@site"
},
"types": {
"@id": "http://localhost:55001/plone/@types"
},
Expand Down
3 changes: 3 additions & 0 deletions src/plone/restapi/tests/http-examples/link.resp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ Content-Type: application/json
"navroot": {
"@id": "http://localhost:55001/plone/link/@navroot"
},
"site": {
"@id": "http://localhost:55001/plone/link/@site"
},
"types": {
"@id": "http://localhost:55001/plone/link/@types"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ Content-Type: application/json
"working_copy_of": null
}
},
"site": {
"@id": "http://localhost:55001/plone/front-page/@site"
},
"types": {
"@id": "http://localhost:55001/plone/front-page/@types"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ Content-Type: application/json
"working_copy_of": null
}
},
"site": {
"@id": "http://localhost:55001/plone/@site"
},
"types": {
"@id": "http://localhost:55001/plone/@types"
},
Expand Down
3 changes: 3 additions & 0 deletions src/plone/restapi/tests/http-examples/newsitem.resp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ Content-Type: application/json
"navroot": {
"@id": "http://localhost:55001/plone/newsitem/@navroot"
},
"site": {
"@id": "http://localhost:55001/plone/newsitem/@site"
},
"types": {
"@id": "http://localhost:55001/plone/newsitem/@types"
},
Expand Down
3 changes: 3 additions & 0 deletions src/plone/restapi/tests/http-examples/search_fullobjects.resp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ Content-Type: application/json
"navroot": {
"@id": "http://localhost:55001/plone/doc1/@navroot"
},
"site": {
"@id": "http://localhost:55001/plone/doc1/@site"
},
"types": {
"@id": "http://localhost:55001/plone/doc1/@types"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ Content-Type: application/json
"working_copy_of": null
}
},
"site": {
"@id": "http://localhost:55001/plone/en/@site"
},
"translations": {
"@id": "http://localhost:55001/plone/en/@translations"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ Content-Type: application/json
"working_copy_of": null
}
},
"site": {
"@id": "http://localhost:55001/plone/en/test-document/@site"
},
"translations": {
"@id": "http://localhost:55001/plone/en/test-document/@translations"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ Content-Type: application/json
"working_copy_of": null
}
},
"site": {
"@id": "http://localhost:55001/plone/@site"
},
"types": {
"@id": "http://localhost:55001/plone/@types"
},
Expand Down
3 changes: 3 additions & 0 deletions src/plone/restapi/tests/http-examples/siteroot.resp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ Content-Type: application/json
"navroot": {
"@id": "http://localhost:55001/plone/@navroot"
},
"site": {
"@id": "http://localhost:55001/plone/@site"
},
"types": {
"@id": "http://localhost:55001/plone/@types"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ Content-Type: application/json
"navroot": {
"@id": "http://localhost:55001/plone/en/test-document/@navroot"
},
"site": {
"@id": "http://localhost:55001/plone/en/test-document/@site"
},
"translations": {
"@id": "http://localhost:55001/plone/en/test-document/@translations",
"items": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ Location: http://localhost:55001/plone/de/mydocument
"navroot": {
"@id": "http://localhost:55001/plone/de/mydocument/@navroot"
},
"site": {
"@id": "http://localhost:55001/plone/de/mydocument/@site"
},
"translations": {
"@id": "http://localhost:55001/plone/de/mydocument/@translations"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ Content-Type: application/json
"navroot": {
"@id": "http://localhost:55001/plone/en/test-document/@navroot"
},
"site": {
"@id": "http://localhost:55001/plone/en/test-document/@site"
},
"translations": {
"@id": "http://localhost:55001/plone/en/test-document/@translations"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ Content-Type: application/json
"navroot": {
"@id": "http://localhost:55001/plone/document/@navroot"
},
"site": {
"@id": "http://localhost:55001/plone/document/@site"
},
"types": {
"@id": "http://localhost:55001/plone/document/@types"
},
Expand Down
3 changes: 3 additions & 0 deletions src/plone/restapi/tests/http-examples/workingcopy_wc_get.resp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ Content-Type: application/json
"navroot": {
"@id": "http://localhost:55001/plone/copy_of_document/@navroot"
},
"site": {
"@id": "http://localhost:55001/plone/copy_of_document/@site"
},
"types": {
"@id": "http://localhost:55001/plone/copy_of_document/@types"
},
Expand Down
42 changes: 42 additions & 0 deletions src/plone/restapi/tests/test_expansion.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,48 @@ def test_types_expanded_in_root(self):
response.json().get("@components").get("types"),
)

def test_site_is_expandable(self):
response = self.api_session.get("/folder")

self.assertEqual(response.status_code, 200)
self.assertIn("site", list(response.json().get("@components")))

def test_site_expanded(self):
response = self.api_session.get("/folder", params={"expand": "site"})

self.assertEqual(response.status_code, 200)
self.assertEqual(
response.json().get("@components").get("site").get("plone.site_title"),
"Plone site",
)
self.assertIn("plone.site_logo", response.json().get("@components").get("site"))
self.assertIn(
"plone.robots_txt", response.json().get("@components").get("site")
)
self.assertIn(
"plone.allowed_sizes", response.json().get("@components").get("site")
)
self.assertIn(
"plone.available_languages",
response.json().get("@components").get("site"),
)
self.assertIn(
"plone.default_language",
response.json().get("@components").get("site"),
)
self.assertEqual(
response.json().get("@components").get("site").get("plone.portal_timezone"),
"UTC",
)
self.assertEqual(
response.json()
.get("@components")
.get("site")
.get("features")
.get("multilingual"),
False,
)


class TestTranslationExpansionFunctional(unittest.TestCase):
layer = PLONE_RESTAPI_DX_PAM_FUNCTIONAL_TESTING
Expand Down