Commit 40f1a34a authored by iv's avatar iv

ERP5Workflow: move copyWorkflow from a test to WorkflowTool

parent 24f587a8
......@@ -19,21 +19,8 @@ class TestERP5WorkflowMixin(testWorkflowMixin, object):
self.copyWorkflow(self.portal.portal_workflow, self.initial_dc_interaction_workflow_id, self.interaction_workflow_id)
def copyWorkflow(self, portal_workflow, old_wf_id, new_wf_id):
"""
Create a copy of old_wf_id workflow
(overwrites existing object with new_wf_id ID if any)
"""
# Copy old_wf_id
copy = portal_workflow.manage_copyObjects(ids=[old_wf_id])
pasted = portal_workflow.manage_pasteObjects(copy)
pasted_workflow_id = pasted[0]['new_id']
# Delete possibly existing object with new_wf_id ID
if getattr(portal_workflow, new_wf_id, None):
portal_workflow.manage_delObjects(new_wf_id)
portal_workflow.manage_renameObjects(ids=[pasted_workflow_id,], new_ids=[new_wf_id,])
self.tic()
portal_workflow.copyWorkflow(old_wf_id, new_wf_id)
self.commit()
def getTestObject(self):
self.portal = self.getPortal()
......@@ -217,7 +204,6 @@ class TestConvertedWorkflow(TestERP5WorkflowMixin):
def test_13_permission(self):
"""
test permission/role mapping on states (ERP5 Workflow only)
# XXX(WORKFLOW) move this test to testERP5Workflow?
"""
portal_workflow = self.portal.portal_workflow
......@@ -351,4 +337,4 @@ def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestDCWorkflow))
suite.addTest(unittest.makeSuite(TestConvertedWorkflow))
return suite
\ No newline at end of file
return suite
......@@ -168,6 +168,24 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
return True
return False
def copyWorkflow(self, old_workflow_id, new_workflow_id):
"""
Create a copy of old_workflow_id workflow
(overwrites existing object with new_workflow_id ID if any)
"""
# Copy old_workflow_id
copy = self.manage_copyObjects(ids=[old_workflow_id])
pasted = self.manage_pasteObjects(copy)
pasted_workflow_id = pasted[0]['new_id']
# Delete possibly existing object with new_workflow_id ID
if getattr(self, new_workflow_id, None):
self.manage_delObjects(new_workflow_id)
self.manage_renameObjects(ids=[pasted_workflow_id,],
new_ids=[new_workflow_id,])
def doActionFor(self, ob, action, wf_id=None, *args, **kw):
workflow_list = self.getWorkflowsFor(ob.getPortalType())
action_ref = action
......
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