Commit ff624fd2 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

ERP5Workflow: newly added permission should be acquired for all existing states.

before, all permissions became acquired in all states once we update permission list.
parent 9669af24
...@@ -173,12 +173,17 @@ class TestERP5Workflow(ERP5TypeTestCase): ...@@ -173,12 +173,17 @@ class TestERP5Workflow(ERP5TypeTestCase):
state1.getStatePermissionRoleListDict(), state1.getStatePermissionRoleListDict(),
{k: () for k in permission_list}, {k: () for k in permission_list},
) )
state1.setAcquirePermissionList(['View'])
state1.setStatePermissionRoleListDict( state1.setStatePermissionRoleListDict(
{k: ['Assignor', 'Manager'] for k in permission_list}, {k: ['Assignor', 'Manager'] for k in permission_list},
) )
workflow.setWorkflowManagedPermissionList( workflow.setWorkflowManagedPermissionList(
permission_list + ['Delete objects'] permission_list + ['Delete objects']
) )
self.assertEqual(
state1.getAcquirePermissionList(),
['View', 'Delete objects'],
)
self.assertEqual( self.assertEqual(
state1.getStatePermissionRoleListDict(), state1.getStatePermissionRoleListDict(),
{ {
......
...@@ -1440,11 +1440,15 @@ class Workflow(XMLObject): ...@@ -1440,11 +1440,15 @@ class Workflow(XMLObject):
return res return res
def _setWorkflowManagedPermissionList(self, permission_list): def _setWorkflowManagedPermissionList(self, permission_list):
current_permission_list = self.getWorkflowManagedPermissionList()
self._baseSetWorkflowManagedPermission(permission_list) self._baseSetWorkflowManagedPermission(permission_list)
# Add/remove the added/removed Workflow permissions to each state # Add/remove the added/removed Workflow permissions to each state
for state in self.getStateValueList(): for state in self.getStateValueList():
state.setAcquirePermissionList(permission_list) state.setAcquirePermissionList(
[e for e in state.getAcquirePermissionList() if e in permission_list] + \
list(set(permission_list) - set(current_permission_list))
)
permission_role_list_dict = state.getStatePermissionRoleListDict() permission_role_list_dict = state.getStatePermissionRoleListDict()
state.setStatePermissionRoleListDict({ state.setStatePermissionRoleListDict({
......
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