Commit 635bb7c1 authored by iv's avatar iv

ERP5Workflow: start moving type-workflow association from chain_dict to portal_types

parent 43492f4c
......@@ -20,12 +20,9 @@ def catalog_translation_list(object_list):
object_list = []
portal_workflow = context.portal_workflow
portal_type_list = context.portal_types.objectValues()
chain_dict = portal_workflow.getChainsByType()
for portal_type in portal_type_list:
associated_workflow_id_list = []
associated_workflow_id_list.extend(portal_type.getTypeWorkflowList())
if portal_type.id in chain_dict:
associated_workflow_id_list.extend(list(chain_dict[portal_type.id]))
for wf_id in associated_workflow_id_list:
wf = getattr(context.portal_workflow, wf_id, None)
if wf is None:
......
......@@ -81,7 +81,7 @@ from webdav.client import Resource
from zLOG import LOG, INFO, WARNING
"""
Most of the codes in this file are copy-pasted from patches/WorkflowTool.py.
Most of the code in this file has been taken from patches/WorkflowTool.py.
"""
_marker = [] # Create a new marker object.
......@@ -115,6 +115,7 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
_manage_selectWorkflows = OriginalWorkflowTool._manage_selectWorkflows
manage_selectWorkflows = OriginalWorkflowTool.manage_selectWorkflows
manage_changeWorkflows = OriginalWorkflowTool.manage_changeWorkflows
# Declarative properties
property_sheets = (
PropertySheet.Base,
......@@ -377,8 +378,7 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
state_path = 'destination/' + '/'.join(state.getPath().split('/')[2:])
tdef.setCategoryList([state_path])
# worklists (portal_type = Worklist)
for qid in dc_workflow.worklists:
qdef = dc_workflow.worklists.get(qid)
for qid, qdef in dc_workflow.worklists.items():
worklist = workflow.newContent(portal_type='Worklist', temp_object=is_temporary)
worklist.setTitle(qdef.title)
worklist.setReference(qdef.id)
......@@ -410,7 +410,7 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
if isinstance(values, Expression):
worklist_variable_value.setVariableExpression(values.text)
else:
worklist_variable_value.setVariableValue(values[0]) #to be changed
worklist_variable_value.setVariableValue(values[0]) #to be changed?
worklist.setActboxUrl(qdef.actbox_url)
worklist.setActboxCategory(qdef.actbox_category)
......@@ -565,15 +565,15 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
type_workflow_dict = self.getChainsByType()
type_tool = self.getPortalObject().portal_types
for ptype_id in type_workflow_dict:
ptype = type_tool._getOb(ptype_id, None)
if ptype is not None and workflow_id in type_workflow_dict[ptype_id]:
for portal_type_id in type_workflow_dict:
portal_type = type_tool._getOb(portal_type_id, None)
if portal_type is not None and workflow_id in type_workflow_dict[portal_type_id]:
# 1. clean DC workflow assignement:
self.delTypeCBT(ptype_id, workflow_id)
self.delTypeCBT(portal_type_id, workflow_id)
# 2. assign ERP5 Workflow to portal type:
type_workflow_list = ptype.getTypeWorkflowList()
type_workflow_list = portal_type.getTypeWorkflowList()
if workflow_id not in type_workflow_list:
ptype.setTypeWorkflowList(
portal_type.setTypeWorkflowList(
type_workflow_list + [workflow_id]
)
......@@ -588,19 +588,18 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
# be done, just go back to whatever you are doing.
type_workflow_dict = self.getChainsByType()
type_tool = self.getPortalObject().portal_types
erp5_workflow_list = []
for ptype_id in type_workflow_dict:
ptype = type_tool._getOb(ptype_id, None)
if ptype is not None:
for workflow_id in type_workflow_dict[ptype_id]:
for portal_type_id in type_workflow_dict:
portal_type = type_tool._getOb(portal_type_id, None)
if portal_type is not None:
for workflow_id in type_workflow_dict[portal_type_id]:
workflow = getattr(self, workflow_id, None)
if workflow and workflow.getPortalType() in ['Workflow', 'Interaction Workflow']:
if workflow and workflow.getPortalType() in ['Workflow', 'Interaction Workflow', 'DCWorkflowDefinition', 'InteractionWorkflowDefinition']:
# 1. clean DC workflow assignement:
self.delTypeCBT(ptype.id, workflow.id)
self.delTypeCBT(portal_type.id, workflow.id)
# 2. assign ERP5 Workflow to portal type:
type_workflow_list = ptype.getTypeWorkflowList()
type_workflow_list = portal_type.getTypeWorkflowList()
if workflow_id not in type_workflow_list:
ptype.setTypeWorkflowList(
portal_type.setTypeWorkflowList(
type_workflow_list + [workflow_id]
)
def getChainDict(self):
......
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