equal
deleted
inserted
replaced
165 super(BaseTransition, self).__init__(*args, **kwargs) |
165 super(BaseTransition, self).__init__(*args, **kwargs) |
166 |
166 |
167 @property |
167 @property |
168 def workflow(self): |
168 def workflow(self): |
169 return self.transition_of[0] |
169 return self.transition_of[0] |
|
170 |
|
171 def has_input_state(self, state): |
|
172 if hasattr(state, 'eid'): |
|
173 state = state.eid |
|
174 return any(s for s in self.reverse_allowed_transition if s.eid == state) |
170 |
175 |
171 def may_be_fired(self, eid): |
176 def may_be_fired(self, eid): |
172 """return true if the logged user may fire this transition |
177 """return true if the logged user may fire this transition |
173 |
178 |
174 `eid` is the eid of the object on which we may fire the transition |
179 `eid` is the eid of the object on which we may fire the transition |
231 id = 'Transition' |
236 id = 'Transition' |
232 |
237 |
233 def destination(self): |
238 def destination(self): |
234 return self.destination_state[0] |
239 return self.destination_state[0] |
235 |
240 |
236 def has_input_state(self, state): |
|
237 if hasattr(state, 'eid'): |
|
238 state = state.eid |
|
239 return any(s for s in self.reverse_allowed_transition if s.eid == state) |
|
240 |
|
241 |
241 |
242 class WorkflowTransition(BaseTransition): |
242 class WorkflowTransition(BaseTransition): |
243 """customized class for WorkflowTransition entities""" |
243 """customized class for WorkflowTransition entities""" |
244 id = 'WorkflowTransition' |
244 id = 'WorkflowTransition' |
245 |
245 |
360 return self.cwetype_workflow() |
360 return self.cwetype_workflow() |
361 |
361 |
362 @property |
362 @property |
363 def current_workflow(self): |
363 def current_workflow(self): |
364 """return current workflow applied to this entity""" |
364 """return current workflow applied to this entity""" |
365 return self.current_state.workflow |
365 return self.current_state and self.current_state.workflow or self.main_workflow |
366 |
366 |
367 @property |
367 @property |
368 def current_state(self): |
368 def current_state(self): |
369 """return current state entity""" |
369 """return current state entity""" |
370 return self.in_state and self.in_state[0] or None |
370 return self.in_state and self.in_state[0] or None |