Skip to content

Commit

Permalink
added code
Browse files Browse the repository at this point in the history
  • Loading branch information
Akshat2Jain committed Aug 18, 2023
1 parent ad8f37c commit 5acf617
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 6 deletions.
10 changes: 10 additions & 0 deletions docs/source/endpoints/translations.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,15 @@ For other content types added later, it would be necessary to enable the behavio

If a simple `GET` request is done on the content item, a new entry will be shown on the `@components` entry, with the URL of the `@translations` endpoint:

```{eval-rst}
.. http:example:: curl httpie python-requests
:request: ../../../src/plone/restapi/tests/http-examples/translations_unexpand_get.req
```

```{literalinclude} ../../../src/plone/restapi/tests/http-examples/translations_unexpand_get.resp
:language: http
```

```{eval-rst}
.. http:example:: curl httpie python-requests
:request: ../../../src/plone/restapi/tests/http-examples/translations_expand_get.req
Expand All @@ -142,3 +151,4 @@ If a simple `GET` request is done on the content item, a new entry will be shown
```{literalinclude} ../../../src/plone/restapi/tests/http-examples/translations_expand_get.resp
:language: http
```

Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
GET /plone/en/test-document?expand=translations HTTP/1.1
Accept: application/json
Authorization: Basic YWRtaW46c2VjcmV0
Content-Type: application/json

{
"id": "http://localhost:55001/plone/es/test-document"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
GET /plone/en/test-document?@translations HTTP/1.1
Accept: application/json
Authorization: Basic YWRtaW46c2VjcmV0
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
HTTP/1.1 200 OK
Content-Type: application/json

{
"@components": {
"actions": {
"@id": "http://localhost:55001/plone/en/test-document/@actions"
},
"aliases": {
"@id": "http://localhost:55001/plone/en/test-document/@aliases"
},
"breadcrumbs": {
"@id": "http://localhost:55001/plone/en/test-document/@breadcrumbs"
},
"contextnavigation": {
"@id": "http://localhost:55001/plone/en/test-document/@contextnavigation"
},
"navigation": {
"@id": "http://localhost:55001/plone/en/test-document/@navigation"
},
"navroot": {
"@id": "http://localhost:55001/plone/en/test-document/@navroot"
},
"translations": {
"@id": "http://localhost:55001/plone/en/test-document/@translations"
},
"types": {
"@id": "http://localhost:55001/plone/en/test-document/@types"
},
"workflow": {
"@id": "http://localhost:55001/plone/en/test-document/@workflow"
}
},
"@id": "http://localhost:55001/plone/en/test-document",
"@type": "Document",
"UID": "SomeUUID000000000000000000000001",
"allow_discussion": false,
"changeNote": "",
"contributors": [],
"created": "1995-07-31T13:45:00+00:00",
"creators": [
"test_user_1_"
],
"description": "",
"effective": null,
"exclude_from_nav": false,
"expires": null,
"id": "test-document",
"is_folderish": false,
"language": {
"title": "English",
"token": "en"
},
"layout": "document_view",
"lock": {
"locked": false,
"stealable": true
},
"modified": "1995-07-31T17:30:00+00:00",
"next_item": {},
"parent": {
"@id": "http://localhost:55001/plone/en",
"@type": "LRF",
"description": "",
"review_state": "published",
"title": "English",
"type_title": "Language Root Folder"
},
"previous_item": {
"@id": "http://localhost:55001/plone/en/assets",
"@type": "LIF",
"description": "",
"title": "Assets",
"type_title": "Language Independent Folder"
},
"relatedItems": [],
"review_state": "private",
"rights": "",
"subjects": [],
"table_of_contents": null,
"text": null,
"title": "Test document",
"type_title": "Page",
"version": "current",
"versioning_enabled": true,
"working_copy": null,
"working_copy_of": null
}
7 changes: 6 additions & 1 deletion src/plone/restapi/tests/test_documentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2169,10 +2169,15 @@ def test_documentation_translations_post(self):
)
save_request_and_response_for_docs("translations_post", response)

def test_documentation_translations_unexpand_get(self):
response = self.api_session.get(
f"{self.en_content.absolute_url()}?@translations",
)
save_request_and_response_for_docs("translations_unexpand_get", response)

def test_documentation_translations_expand_get(self):
response = self.api_session.get(
f"{self.en_content.absolute_url()}?expand=translations",
json={"id": self.es_content.absolute_url()},
)
save_request_and_response_for_docs("translations_expand_get", response)

Expand Down

0 comments on commit 5acf617

Please sign in to comment.