diff --git a/news/1723.bugfix b/news/1723.bugfix new file mode 100644 index 0000000000..dc682e57c5 --- /dev/null +++ b/news/1723.bugfix @@ -0,0 +1 @@ +limits the use of multilingual services only if multilingual is actually installed. @mamico diff --git a/src/plone/restapi/services/multilingual/configure.zcml b/src/plone/restapi/services/multilingual/configure.zcml index 58d65c74d3..8eec6946c0 100644 --- a/src/plone/restapi/services/multilingual/configure.zcml +++ b/src/plone/restapi/services/multilingual/configure.zcml @@ -20,6 +20,7 @@ factory=".pam.TranslationInfo" for="Products.CMFCore.interfaces.IContentish" permission="zope2.View" + layer="plone.app.multilingual.interfaces.IPloneAppMultilingualInstalled" name="@translations" /> @@ -41,6 +43,7 @@ factory=".pam.UnlinkTranslations" for="Products.CMFCore.interfaces.IContentish" permission="plone.app.multilingual.ManageTranslations" + layer="plone.app.multilingual.interfaces.IPloneAppMultilingualInstalled" name="@translations" /> @@ -49,6 +52,7 @@ factory=".locator.TranslationLocator" for="Products.CMFCore.interfaces.IContentish" permission="plone.app.multilingual.ManageTranslations" + layer="plone.app.multilingual.interfaces.IPloneAppMultilingualInstalled" name="@translation-locator" /> diff --git a/src/plone/restapi/tests/test_translations.py b/src/plone/restapi/tests/test_translations.py index c32f72eff8..a8fa3bdd61 100644 --- a/src/plone/restapi/tests/test_translations.py +++ b/src/plone/restapi/tests/test_translations.py @@ -9,6 +9,7 @@ from plone.restapi.bbb import ILanguage from plone.restapi.testing import PLONE_RESTAPI_DX_PAM_FUNCTIONAL_TESTING from plone.restapi.testing import PLONE_RESTAPI_DX_PAM_INTEGRATION_TESTING +from plone.restapi.testing import PLONE_RESTAPI_DX_FUNCTIONAL_TESTING from zope.component import getMultiAdapter from zope.interface import alsoProvides @@ -374,3 +375,30 @@ def test_translation_locator(self): self.assertEqual(200, response.status_code) self.assertEqual(self.portal_url + "/de", response.json().get("@id")) + + +class TestPAMNotinstalled(unittest.TestCase): + layer = PLONE_RESTAPI_DX_FUNCTIONAL_TESTING + + def setUp(self): + self.portal = self.layer["portal"] + self.request = self.layer["request"] + login(self.portal, SITE_OWNER_NAME) + self.folder = createContentInContainer(self.portal, "Folder", title="Folder") + transaction.commit() + + def test_translations(self): + response = requests.get( + f"{self.folder.absolute_url()}/@translations", + headers={"Accept": "application/json"}, + auth=(SITE_OWNER_NAME, SITE_OWNER_PASSWORD), + ) + self.assertEqual(404, response.status_code) + + def test_translation_locator(self): + response = requests.get( + f"{self.folder.absolute_url()}/@translation-locator", + headers={"Accept": "application/json"}, + auth=(SITE_OWNER_NAME, SITE_OWNER_PASSWORD), + ) + self.assertEqual(404, response.status_code)