Skip to content

Commit

Permalink
Fix workflow translations with unicode characters
Browse files Browse the repository at this point in the history
  • Loading branch information
Gagaro committed Jan 9, 2018
1 parent 266a37b commit 4b9a1ff
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Expand Up @@ -12,6 +12,9 @@ Changelog
fields adapters.
[sneridagh]

- Fix workflow translations with unicode characters.
[Gagaro]


1.0a25 (2017-11-23)
-------------------
Expand Down
6 changes: 4 additions & 2 deletions src/plone/restapi/services/workflow/info.py
Expand Up @@ -38,14 +38,16 @@ def __call__(self, expand=False):
transitions.append({
'@id': '{}/@workflow/{}'.format(
self.context.absolute_url(), action['id']),
'title': self.context.translate(action['title']),
'title': self.context.translate(action['title'].decode('utf8')),
})

for item, action in enumerate(history):
history[item]['title'] = self.context.translate(
wftool.getTitleForStateOnType(
action['review_state'],
self.context.portal_type))
self.context.portal_type
).decode('utf8')
)

result['workflow'].update({
'history': json_compatible(history),
Expand Down
6 changes: 4 additions & 2 deletions src/plone/restapi/tests/test_workflow.py
Expand Up @@ -19,9 +19,11 @@ class TestWorkflowInfo(TestCase):

def setUp(self):
self.portal = self.layer['portal']
self.portal.portal_workflow['simple_publication_workflow'].states['published'].title = \
u'Published with accent é'.encode('utf8')
self.request = self.layer['request']
self.doc1 = self.portal[self.portal.invokeFactory(
'Document', id='doc1', title='Test Document')]
'DXTestDocument', id='doc1', title='Test Document')]
wftool = getToolByName(self.portal, 'portal_workflow')
wftool.doActionFor(self.portal.doc1, 'submit')
wftool.doActionFor(self.portal.doc1, 'publish')
Expand All @@ -34,7 +36,7 @@ def test_workflow_info_includes_history(self):
history = info['history']
self.assertEqual(3, len(history))
self.assertEqual('published', history[-1][u'review_state'])
self.assertEqual('Published', history[-1][u'title'])
self.assertEqual(u'Published with accent é', history[-1][u'title'])

def test_workflow_info_includes_transitions(self):
wfinfo = getMultiAdapter((self.doc1, self.request),
Expand Down

0 comments on commit 4b9a1ff

Please sign in to comment.