Commit 81b94a7a authored by iv's avatar iv

ERP5Workflow: fix initialization of permissions on states

during workflow conversion
On DCWorkflow states, when the workflow does not manage permissions,
they may appear in some states's permission_roles dict.
This create wrong permissions, and we should not set them if they are
not managed by the workflow.
parent 782878ed
...@@ -381,6 +381,7 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool): ...@@ -381,6 +381,7 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
transition.setAfterScriptValueList(script_path_list) transition.setAfterScriptValueList(script_path_list)
# create states (portal_type = State) # create states (portal_type = State)
workflow_managed_role_list = workflow.getManagedRoleList()
for sid in dc_workflow.states: for sid in dc_workflow.states:
sdef = dc_workflow.states.get(sid) sdef = dc_workflow.states.get(sid)
state = workflow.newContent(portal_type='State', temp_object=is_temporary) state = workflow.newContent(portal_type='State', temp_object=is_temporary)
...@@ -395,16 +396,17 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool): ...@@ -395,16 +396,17 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
permission_roles_dict = {} permission_roles_dict = {}
if sdef.permission_roles: if sdef.permission_roles:
for (permission, roles) in sdef.permission_roles.items(): for (permission, roles) in sdef.permission_roles.items():
if isinstance(roles, list): # type 'list' means acquisition if permission in dc_workflow.permissions:
acquire_permission_list.append(permission) if isinstance(roles, list): # type 'list' means acquisition
permission_roles_dict[permission] = list(roles) acquire_permission_list.append(permission)
permission_roles_dict[permission] = list(roles)
state.setAcquirePermission(acquire_permission_list) state.setAcquirePermission(acquire_permission_list)
state.setStatePermissionRolesDict(permission_roles_dict) state.setStatePermissionRolesDict(permission_roles_dict)
if permission_roles_dict:
state.setCellRange(sorted(permission_roles_dict.keys()), state.setCellRange(sorted(permission_roles_dict.keys()),
sorted(workflow.getManagedRoleList()), sorted(workflow_managed_role_list),
base_id='cell') base_id='cell')
# default state using category setter # default state using category setter
state_path = getattr(workflow, 'state_'+dc_workflow.initial_state).getPath() state_path = getattr(workflow, 'state_'+dc_workflow.initial_state).getPath()
......
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