Commit 7c9fa6f1 authored by Jérome Perrin's avatar Jérome Perrin Committed by Kazuhiko Shiozaki

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 b741cf46
...@@ -297,6 +297,13 @@ class TestConvertedWorkflow(TestERP5WorkflowMixin): ...@@ -297,6 +297,13 @@ class TestConvertedWorkflow(TestERP5WorkflowMixin):
workflow.setWorkflowManagedPermissionList([]) workflow.setWorkflowManagedPermissionList([])
self.assertEqual(workflow.state_current.getAcquirePermissionList(), []) 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): def test_14_multiple_workflow_different_permission_roles(self):
workflow1 = self.createERP5Workflow('edit_workflow', 'temporary_workflow1') workflow1 = self.createERP5Workflow('edit_workflow', 'temporary_workflow1')
workflow2 = self.createERP5Workflow('edit_workflow', 'temporary_workflow2') workflow2 = self.createERP5Workflow('edit_workflow', 'temporary_workflow2')
......
...@@ -125,7 +125,7 @@ class WorkflowState(IdAsReferenceMixin("state_"), ...@@ -125,7 +125,7 @@ class WorkflowState(IdAsReferenceMixin("state_"),
""" """
if self.state_permission_role_list_dict is None: if self.state_permission_role_list_dict is None:
self.state_permission_role_list_dict = PersistentMapping() 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, security.declareProtected(Permissions.AccessContentsInformation,
'getAvailableTypeList') '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