Commit b534bc87 authored by iv's avatar iv

ERP5Workflow: old chain_dict was used in ERP5Site_getWorkflowStateItemList

keep it as compatibility code but also search for new workflow/portal_type association
directly in portal_type (type_workflow_list)
This fixes some failures in testFunctionalCore
parent dc22d27c
...@@ -22,7 +22,9 @@ result_list = display_none_category and [('', '')] or [] ...@@ -22,7 +22,9 @@ result_list = display_none_category and [('', '')] or []
if isinstance(portal_type, basestring): if isinstance(portal_type, basestring):
portal_type = portal_type, portal_type = portal_type,
### Compatibility code ###
chain_dict = workflow_tool.getWorkflowChainDict() chain_dict = workflow_tool.getWorkflowChainDict()
for portal_type in portal_type: for portal_type in portal_type:
for workflow_id in chain_dict['chain_%s' % portal_type].split(','): for workflow_id in chain_dict['chain_%s' % portal_type].split(','):
...@@ -46,4 +48,26 @@ for portal_type in portal_type: ...@@ -46,4 +48,26 @@ for portal_type in portal_type:
state_set.add(state_id) state_set.add(state_id)
result_list.append((str(translateString(state.title)), state_id)) result_list.append((str(translateString(state.title)), state_id))
### End of compatibility code ###
portal = context.getPortalObject()
if isinstance(portal_type, str):
portal_type = (portal_type,)
for current_type in portal_type:
current_type = getattr(portal.portal_types, current_type)
current_workflow_list = current_type.getTypeWorkflowList()
for workflow_id in current_workflow_list:
if workflow_id not in workflow_set:
workflow_set.add(workflow_id)
workflow = workflow_tool[workflow_id]
state_value_list = workflow.getStateValueList()
if (state_value_list is not None and
len(workflow.getStateIdList()) > 1 and
state_var in (None, workflow.getStateVariable())):
for state in state_value_list:
state_id = state.getReference()
if not state_id in state_set:
state_set.add(state_id)
result_list.append((str(translateString(state.title)), state_id))
return result_list return result_list
...@@ -653,7 +653,7 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool): ...@@ -653,7 +653,7 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
if sorted: if sorted:
dc_workflow_id_list = list(dc_workflow_id_list) dc_workflow_id_list = list(dc_workflow_id_list)
dc_workflow_id_list.sort() dc_workflow_id_list.sort()
portal_type_value = self.getPortalObject().portal_types._getOb(portal_type) portal_type_value = getattr(self.getPortalObject().portal_types, portal_type)
workflow_id_list = portal_type_value.getTypeWorkflowList() workflow_id_list = portal_type_value.getTypeWorkflowList()
workflow_id_list.extend(dc_workflow_id_list) workflow_id_list.extend(dc_workflow_id_list)
return_dict['chain_%s' % portal_type] = ', '.join(workflow_id_list) return_dict['chain_%s' % portal_type] = ', '.join(workflow_id_list)
......
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