Commit 0ea77886 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

fixup! erp5_web: introduce translatable path.

parent 470188fd
...@@ -461,9 +461,10 @@ class WebSection(Domain, DocumentExtensibleTraversableMixin): ...@@ -461,9 +461,10 @@ class WebSection(Domain, DocumentExtensibleTraversableMixin):
parent = aq_parent(aq_inner(self)) parent = aq_parent(aq_inner(self))
parent_url = getattr(parent, 'absolute_translated_url', parent.absolute_url)(relative=relative) parent_url = getattr(parent, 'absolute_translated_url', parent.absolute_url)(relative=relative)
original_document = self.getOriginalDocument() original_document = self.getOriginalDocument()
return self._add_trailing_slash( return '/'.join([
self._add_trailing_slash(parent_url) + \ parent_url,
getattr(original_document, 'getTranslatedTranslatableId', original_document.getId)()) getattr(original_document, 'getTranslatedTranslatableId', original_document.getId)()
])
security.declareProtected(Permissions.View, 'getSiteMapTree') security.declareProtected(Permissions.View, 'getSiteMapTree')
def getSiteMapTree(self, **kw): def getSiteMapTree(self, **kw):
......
...@@ -1626,6 +1626,7 @@ Hé Hé Hé!""", page.asText().strip()) ...@@ -1626,6 +1626,7 @@ Hé Hé Hé!""", page.asText().strip())
# After setting /fr/ccc => /aaa as well, we have no conflict. # After setting /fr/ccc => /aaa as well, we have no conflict.
section1.setFrTranslatedTranslatableId('ccc') section1.setFrTranslatedTranslatableId('ccc')
self.tic() self.tic()
website_absolute_url = website.absolute_url()
website_path = website.absolute_url_path() website_path = website.absolute_url_path()
# /fr/ccc/ is /aaa/ # /fr/ccc/ is /aaa/
response = self.publish(website_path + '/fr/ccc/') response = self.publish(website_path + '/fr/ccc/')
...@@ -1638,7 +1639,12 @@ Hé Hé Hé!""", page.asText().strip()) ...@@ -1638,7 +1639,12 @@ Hé Hé Hé!""", page.asText().strip())
# /fr/bbb/ should be redirected to /fr/aaa/ # /fr/bbb/ should be redirected to /fr/aaa/
response = self.publish(website_path + '/fr/bbb/') response = self.publish(website_path + '/fr/bbb/')
self.assertEqual(MOVED_TEMPORARILY, response.status) self.assertEqual(MOVED_TEMPORARILY, response.status)
self.assertEqual(website.absolute_url() + '/fr/aaa/', response.getHeader('Location')) self.assertEqual(website_absolute_url + '/fr/aaa/', response.getHeader('Location'))
# check absolute_translated_url()
with self.portal.Localizer.translationContext('fr'):
self.assertEqual(website_absolute_url + '/fr', website.absolute_translated_url())
self.assertEqual(website_absolute_url + '/fr/ccc', website['aaa'].absolute_translated_url())
self.assertEqual(website_absolute_url + '/fr/aaa', website['bbb'].absolute_translated_url())
class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase): class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase):
""" """
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment