[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
--- 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
--- 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'<p>%s</p>\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):