workflows: fix export/import of computed roles with unicode characters (#25301)
This commit is contained in:
parent
bb064934b3
commit
0862a94bf7
|
@ -1,3 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import pytest
|
||||
import sys
|
||||
import shutil
|
||||
|
@ -125,6 +127,13 @@ def test_action_dispatch(pub):
|
|||
wf2 = assert_import_export_works(wf)
|
||||
assert(wf2.possible_status[0].items[0].role_id == 'Role [form_var_foo]')
|
||||
|
||||
dispatch.role_id = 'Rolé [form_var_foo]'
|
||||
wf2 = assert_import_export_works(wf, include_id=False)
|
||||
assert wf2.possible_status[0].items[0].role_id == 'Rolé [form_var_foo]'
|
||||
|
||||
dispatch.role_id = 'Rolé [form_var_foo]'
|
||||
wf2 = assert_import_export_works(wf, include_id=True)
|
||||
assert wf2.possible_status[0].items[0].role_id == 'Rolé [form_var_foo]'
|
||||
|
||||
def test_status_actions_named_role(pub):
|
||||
wf = Workflow(name='status')
|
||||
|
|
|
@ -878,7 +878,7 @@ class XmlSerialisable(object):
|
|||
try:
|
||||
role = unicode(Role.get(role_id).name, charset)
|
||||
except KeyError:
|
||||
role = unicode(role_id, charset)
|
||||
role_id = role = unicode(role_id, charset)
|
||||
sub = ET.SubElement(item, attribute)
|
||||
if include_id:
|
||||
sub.attrib['role_id'] = role_id
|
||||
|
@ -898,11 +898,12 @@ class XmlSerialisable(object):
|
|||
if include_id:
|
||||
if not 'role_id' in elem.attrib:
|
||||
return None
|
||||
role_id = str(elem.attrib['role_id'])
|
||||
role_id = elem.attrib['role_id'].encode(charset)
|
||||
if Role.has_key(role_id):
|
||||
return role_id
|
||||
else:
|
||||
return None
|
||||
if WorkflowStatusItem.get_expression(role_id)['type'] in ('python', 'template'):
|
||||
return role_id
|
||||
return None
|
||||
|
||||
# if not using id, look up on the name
|
||||
for role in Role.select(ignore_errors=True):
|
||||
|
|
Loading…
Reference in New Issue