Commit f4cd9eb2 authored by Jérome Perrin's avatar Jérome Perrin

worklfow: save state permissions sorted

When editing a state permission mapping the roles were not sorted,
because WorkflowState_getPermissionMatrixContext uses a set. Sort
before setting the attribute, to prevent useless diffs in ZODB history
and business template.
parent 4a994f3e
......@@ -297,6 +297,13 @@ class TestConvertedWorkflow(TestERP5WorkflowMixin):
workflow.setWorkflowManagedPermissionList([])
self.assertEqual(workflow.state_current.getAcquirePermissionList(), [])
# check the permissions are saved sorted in a canonical form: sorted and as
# tuple
workflow.state_current.setPermission(permission, ['Auditor', 'Assignor'])
self.assertEqual(
workflow.state_current.getStatePermissionRoleListDict().get(permission),
('Assignor', 'Auditor'))
def test_14_multiple_workflow_different_permission_roles(self):
workflow1 = self.createERP5Workflow('edit_workflow', 'temporary_workflow1')
workflow2 = self.createERP5Workflow('edit_workflow', 'temporary_workflow2')
......
......@@ -125,7 +125,7 @@ class WorkflowState(IdAsReferenceMixin("state_"),
"""
if self.state_permission_role_list_dict is None:
self.state_permission_role_list_dict = PersistentMapping()
self.state_permission_role_list_dict[permission] = tuple(roles)
self.state_permission_role_list_dict[permission] = tuple(sorted(roles))
security.declareProtected(Permissions.AccessContentsInformation,
'getAvailableTypeList')
......
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