Skip to content

Commit

Permalink
Refactor parameter names to snake case
Browse files Browse the repository at this point in the history
  • Loading branch information
sneridagh committed Mar 30, 2020
1 parent 39ef9d1 commit c131f06
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions src/plone/restapi/services/content/add.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def reply(self):
type_ = data.get("@type", None)
id_ = data.get("id", None)
title = data.get("title", None)
translationOf = data.get("translationOf", None)
translation_of = data.get("translation_of", None)
language = data.get("language", None)

if not type_:
Expand Down Expand Up @@ -88,7 +88,7 @@ def reply(self):

obj = add(self.context, obj, rename=not bool(id_))

# Link translation given the translationOf property
# Link translation given the translation_of property
if PAM_INSTALLED:
from plone.app.multilingual.interfaces import (
IPloneAppMultilingualInstalled,
Expand All @@ -97,10 +97,10 @@ def reply(self):

if (
IPloneAppMultilingualInstalled.providedBy(self.request)
and translationOf
and translation_of
and language
):
source = self.get_object(translationOf)
source = self.get_object(translation_of)
if source:
manager = ITranslationManager(source)
manager.register_translation(language, obj)
Expand Down
2 changes: 1 addition & 1 deletion src/plone/restapi/services/multilingual/locator.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class TranslationLocator(Service):
"""

def reply(self):
target_language = self.request.form["targetLanguage"]
target_language = self.request.form["target_language"]

locator = ITranslationLocator(self.context)
parent = locator(target_language)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
GET /plone/es/test-document/@translation-locator?targetLanguage=de HTTP/1.1
GET /plone/es/test-document/@translation-locator?target_language=de HTTP/1.1
Accept: application/json
Authorization: Basic YWRtaW46c2VjcmV0
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ Content-Type: application/json
"id": "mydocument",
"language": "de",
"title": "My German Document",
"translationOf": "SomeUUID000000000000000000000003"
}
"translation_of": "SomeUUID000000000000000000000003"
}
4 changes: 2 additions & 2 deletions src/plone/restapi/tests/test_documentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1622,15 +1622,15 @@ def test_documentation_translations_link_on_post(self):
"@type": "Document",
"id": "mydocument",
"title": "My German Document",
"translationOf": self.es_content.UID(),
"translation_of": self.es_content.UID(),
"language": "de",
},
)
save_request_and_response_for_docs("translations_link_on_post", response)

def test_documentation_translation_locator(self):
response = self.api_session.get(
"{}/@translation-locator?targetLanguage=de".format(
"{}/@translation-locator?target_language=de".format(
self.es_content.absolute_url()
),
headers={"Accept": "application/json"},
Expand Down
4 changes: 2 additions & 2 deletions src/plone/restapi/tests/test_translations.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def test_post_to_folder_creates_document_translated(self):
"@type": "Document",
"id": "mydocument",
"title": "My Document DE",
"translationOf": self.es_content.UID(),
"translation_of": self.es_content.UID(),
"language": "de",
},
)
Expand Down Expand Up @@ -269,7 +269,7 @@ def setUp(self):

def test_translation_locator(self):
response = requests.get(
"{}/@translation-locator?targetLanguage=de".format(
"{}/@translation-locator?target_language=de".format(
self.es_content.absolute_url()
),
headers={"Accept": "application/json"},
Expand Down

0 comments on commit c131f06

Please sign in to comment.