Commit 29441d75 authored by Jérome Perrin's avatar Jérome Perrin

ERP5Workflow: fix adding permissions

Follow up of ff624fd2 (ERP5Workflow: newly added permission should be
acquired for all existing states., 2024-11-04) and cbef6282 (ERP5Workflow:
make sure not create duplicate permissions, 2024-11-05)
parent cbef6282
Pipeline #37869 canceled with stage
in 0 seconds
......@@ -194,6 +194,21 @@ class TestERP5Workflow(ERP5TypeTestCase):
},
)
workflow.setWorkflowManagedPermissionList(permission_list)
self.assertEqual(
state1.getAcquirePermissionList(),
['View'],
)
self.assertEqual(
state1.getStatePermissionRoleListDict(),
{
'Access contents information': ('Assignor', 'Manager'),
'Delete objects': (),
'Modify portal content': ('Assignor', 'Manager'),
'View': ('Assignor', 'Manager'),
},
)
def test_afterScript(self):
workflow = self.workflow_module.newContent(
......
......@@ -1440,16 +1440,15 @@ class Workflow(XMLObject):
return res
def _setWorkflowManagedPermissionList(self, permission_list):
current_permission_list = self.getWorkflowManagedPermissionList()
added_permission_set = set(permission_list) - set(self.getWorkflowManagedPermissionList())
self._baseSetWorkflowManagedPermission(permission_list)
# Add/remove the added/removed Workflow permissions to each state
for state in self.getStateValueList():
current_acquire_permission_set_or_added_permission_set = \
set(state.getAcquirePermissionList()) | added_permission_set
state.setAcquirePermissionList(
list(
{e for e in state.getAcquirePermissionList() if e in permission_list}
| (set(permission_list) - set(current_permission_list))))
[e for e in permission_list
if e in current_acquire_permission_set_or_added_permission_set])
permission_role_list_dict = state.getStatePermissionRoleListDict()
state.setStatePermissionRoleListDict({
permission: permission_role_list_dict.get(permission, [])
......
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