Commit 0a361ce6 authored by iv's avatar iv

ERP5Workflow: rename and clean doActionFor and isActionSupported

parent 915a2451
......@@ -182,15 +182,14 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
Returns a true value if the given action name
is possible in the current state.
'''
sdef = self._getWorkflowStateOf(document, id_only=0)
if sdef is None:
state = self._getWorkflowStateOf(document, id_only=0)
if state is None:
return 0
if action in sdef.getDestinationIdList():
tdef = self._getOb(action, None)
if (tdef is not None and
tdef.getTriggerType() == TRIGGER_USER_ACTION and
self._checkTransitionGuard(tdef, document, **kw)):
if action in state.getDestinationIdList():
transition = self._getOb(action, None)
if (transition is not None and
transition.getTriggerType() == TRIGGER_USER_ACTION and
self._checkTransitionGuard(transition, document, **kw)):
return 1
return 0
......
......@@ -191,17 +191,13 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
def doActionFor(self, ob, action, wf_id=None, *args, **kw):
workflow_list = self.getWorkflowsFor(ob.getPortalType())
action_ref = action
if wf_id is None:
if workflow_list == []:
raise WorkflowException(_(u'No workflows found.'))
found = 0
for wf in workflow_list:
if wf.getPortalType() == 'Workflow':
# workflow compatibility
action = 'transition_' + action_ref
else:
action = action_ref
action = 'transition_' + action
if wf.isActionSupported(ob, action, **kw):
found = 1
break
......@@ -213,10 +209,10 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
if wf is None:
raise WorkflowException(_(u'Requested workflow definition not found.'))
if wf.getPortalType() == 'Workflow':
# workflow compatibility
action = 'transition_' + action_ref
return self._invokeWithNotification(
action = 'transition_' + action
result = self._invokeWithNotification(
workflow_list, ob, action, wf.doActionFor, (ob, action) + args, kw)
return result
security.declareProtected(Permissions.AccessContentsInformation,
'getWorkflowValueListFor')
......
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