# HG changeset patch # User Sylvain Thénault # Date 1266570264 -3600 # Node ID 322c3dd96dd5a6fc8acf160f7352920b3bde065f # Parent fd4e32f172118b7222a8d9eba031712fc2e0be76 [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 diff -r fd4e32f17211 -r 322c3dd96dd5 entities/wfobjs.py --- a/entities/wfobjs.py Fri Feb 19 09:37:03 2010 +0100 +++ b/entities/wfobjs.py Fri Feb 19 10:04:24 2010 +0100 @@ -266,6 +266,12 @@ except IndexError: return entity.latest_trinfo().previous_state + def potential_destinations(self): + try: + 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 @@ 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 diff -r fd4e32f17211 -r 322c3dd96dd5 web/views/workflow.py --- a/web/views/workflow.py Fri Feb 19 09:37:03 2010 +0100 +++ b/web/views/workflow.py Fri Feb 19 10:04:24 2010 +0100 @@ -69,7 +69,7 @@ entity.view('oneline'))) 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'

%s

\n' % msg) self.w(form.render()) @@ -318,7 +318,8 @@ 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):