Commit 22e10de5 authored by Sylvain Thénault's avatar Sylvain Thénault
Browse files

[workflow] finish refactoring introduced by 021035b9a7ab for 'go back' transition:

* fix SubWorkflowTransition.destination() prototype (must now take an entity as argument)
* fix the change state for to give the entity to the transition's destination() method
* we need a new method to draw workflow since we've no entity to give and 'go back'
  transition usually go back to multiple states

branch : stable
parent fd4e32f17211
......@@ -266,6 +266,12 @@ class Transition(BaseTransition):
except IndexError:
return entity.latest_trinfo().previous_state
def potential_destinations(self):
yield self.destination_state[0]
except IndexError:
for state in self.reverse_allowed_transition:
yield state
def parent(self):
return self.workflow
......@@ -279,9 +285,12 @@ class WorkflowTransition(BaseTransition):
def subwf(self):
return self.subworkflow[0]
def destination(self):
def destination(self, entity):
return self.subwf.initial
def potential_destinations(self):
yield self.subwf.initial
def add_exit_point(self, fromstate, tostate):
if hasattr(fromstate, 'eid'):
fromstate = fromstate.eid
......@@ -69,7 +69,7 @@ class ChangeStateFormView(form.FormViewMixIn, view.EntityView):
msg = self.req._('status will change from %(st1)s to %(st2)s') % {
'st1': entity.printable_state,
'st2': self._cw._(transition.destination().name)}
'st2': self._cw._(transition.destination(entity).name)}
self.w(u'<p>%s</p>\n' % msg)
......@@ -318,7 +318,8 @@ class WorkflowVisitor:
for transition in self.entity.reverse_transition_of:
for incomingstate in transition.reverse_allowed_transition:
yield incomingstate.eid, transition.eid, transition
yield transition.eid, transition.destination().eid, transition
for outgoingstate in transition.potential_destinations():
yield transition.eid, outgoingstate.eid, transition
class WorkflowImageView(TmpFileViewMixin, view.EntityView):
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