Commit 5bfb680a authored by Jérome Perrin's avatar Jérome Perrin

Fix double translation of worklist in ERP5JS

from nexedi/erp5@45c03413 (comment 171160)

See merge request nexedi/erp5!1689
parents 59f1ea5b 52b25e02
......@@ -1546,10 +1546,11 @@ def calculateHateoas(is_portal=None, is_site_root=None, traversed_document=None,
'href': '%s' % view_action['url'],
'name': view_action['id'],
'icon': view_action['icon'],
'title': Base_translateString(
translateWorklistActionName(view_action['title'])
if 'worklist_id' in view_action
else view_action['title']),
'title': translateWorklistActionName(
view_action['title']
) if 'worklist_id' in view_action else Base_translateString(
view_action['title']
),
})
global_action_type = ("view", "workflow", "object_new_content_action",
......
......@@ -65,6 +65,7 @@ def simulate(script_id, params_string, code_string):
try:
result = f(self, *args, **kw)
finally:
transaction.abort()
if script_id in self.portal.portal_skins.custom.objectIds():
self.portal.portal_skins.custom.manage_delObjects(script_id)
transaction.commit()
......@@ -159,18 +160,12 @@ def replace_request(new_request, context):
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
#####################################################
# Base_getRequestHeader
#####################################################
class ERP5HALJSONStyleSkinsMixin(ERP5TypeTestCase):
def afterSetUp(self):
self.login()
wipeFolder(self.portal.foo_module, commit=False)
def beforeTearDown(self):
transaction.abort()
def generateNewId(self):
return "%sö" % self.portal.portal_ids.generateNewId(
id_group=('erp5_hal_json_style_test'))
......@@ -184,6 +179,10 @@ class ERP5HALJSONStyleSkinsMixin(ERP5TypeTestCase):
)
return foo
#####################################################
# Base_getRequestHeader
#####################################################
class TestBase_getRequestHeader(ERP5HALJSONStyleSkinsMixin):
@changeSkin('Hal')
def test_getRequestHeader_REQUEST_disallowed(self):
......@@ -2437,8 +2436,9 @@ class TestERP5Person_getHateoas_mode_search(ERP5HALJSONStyleSkinsMixin):
self.tic()
def beforeTearDown(self):
super(TestERP5Person_getHateoas_mode_search, self).beforeTearDown()
self.portal.person_module.deleteContent(self.person.getId())
self.tic()
@simulate('Base_getRequestUrl', '*args, **kwargs', 'return "http://example.org/bar"')
@simulate('Base_getRequestHeader', '*args, **kwargs', 'return "application/hal+json"')
......@@ -2843,6 +2843,16 @@ if translation_service is not None :\n\
pass\n\
return msg"
def afterSetUp(self):
super(TestERP5Document_getHateoas_translation, self).afterSetUp()
self.portal.Base_createUITestLanguages()
param_dict = [
{ 'message': 'Title', 'translation': 'biaoti', 'language': 'wo'},
{ 'message': 'Draft To Validate', 'translation': 'daiyanzhen', 'language': 'wo'},
{ 'message': 'Foo', 'translation': 'Foo_zhongwen', 'language': 'wo'}]
for tmp in param_dict:
self.portal.Base_addUITestTranslation(message = tmp['message'], translation = tmp['translation'], language = tmp['language'])
@simulate('Base_getRequestUrl', '*args, **kwargs',
'return "http://example.org/bar"')
@simulate('Base_getRequestHeader', '*args, **kwargs',
......@@ -2852,13 +2862,6 @@ return msg"
@changeSkin('Hal')
def test_getHateoasBulk_default_view_translation(self):
self.portal.Base_createUITestLanguages()
param_dict = [
{ 'message': 'Title', 'translation': 'biaoti', 'language': 'wo'},
{ 'message': 'Draft To Validate', 'translation': 'daiyanzhen', 'language': 'wo'},
{ 'message': 'Foo', 'translation': 'Foo_zhongwen', 'language': 'wo'}]
for tmp in param_dict:
self.portal.Base_addUITestTranslation(message = tmp['message'], translation = tmp['translation'], language = tmp['language'])
document = self._makeDocument()
fake_request = do_fake_request("POST")
......@@ -2942,9 +2945,8 @@ return msg"
# worklists with the actual count of document
fake_request = do_fake_request("GET")
default_gettext = self.portal.Localizer.erp5_ui.gettext
def gettext(message, **kw):
return default_gettext(message, **kw)
return kw.get('default', message)
with mock.patch.object(self.portal.Localizer.erp5_ui.__class__, 'gettext', side_effect=gettext) as gettext_mock:
self.portal.web_site_module.hateoas.ERP5Document_getHateoas(
......
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