Skip to content

Commit

Permalink
added code below expansion colon
Browse files Browse the repository at this point in the history
  • Loading branch information
Akshat2Jain committed Aug 4, 2023
1 parent 08213f2 commit c6d91e1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
12 changes: 9 additions & 3 deletions docs/source/endpoints/translations.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ To unlink the content, issue a `DELETE` request on the `@translations` endpoint
:language: http
```


## Creating a translation from an existing content

The `POST` content endpoint to a folder is also capable of linking this new content with an
Expand All @@ -107,7 +106,6 @@ exising translation using two parameters: `translationOf` and `language`.
:language: http
```


## Get location in the tree for new translations

When you create a translation in Plone, there are policies in place for finding a suitable placement for it.
Expand All @@ -122,9 +120,17 @@ This endpoint returns the proper placement for the newly created translation:
:language: http
```


## Expansion

This endpoint can be used with the {doc}`expansion` mechanism which allows getting additional information about a content item in one query, avoiding unnecessary requests.

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_expand_get.req
```

```{literalinclude} ../../../src/plone/restapi/tests/http-examples/translations_expand_get.resp
:language: http
```
7 changes: 7 additions & 0 deletions src/plone/restapi/tests/test_documentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2168,6 +2168,13 @@ def test_documentation_translations_post(self):
json={"id": self.es_content.absolute_url()},
)
save_request_and_response_for_docs("translations_post", 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)

def test_documentation_translations_post_by_id(self):
response = self.api_session.post(
Expand Down

0 comments on commit c6d91e1

Please sign in to comment.