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