You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Great app, I was looking for something like it for a while. Thanks a whole bunch!
One small suggestion:
instead of returning True on object.get_state_info().test_transition('transition_name', user)
it would probably better to return state_info instance, so the call can be chained:
try:
object.get_state_info().test_transition('transition_name', user).make_transition('transition_name', user)
except States2Exception as e:
raise ValidationError("Cannot changes state because %s" % e)
instead of:
try:
if object.get_state_info().test_transition('transition_name', user):
object.get_state_info().make_transition('transition_name', user)
except States2Exception as e:
raise ValidationError("Cannot changes state because %s" % e)
This way it is type consistent (test_transition never returns False anyhow), it is more DRY and by chaining calls like that we could also eliminate failed transition logs in a more concise way.
I would submit a pull request myself, but it is literally a one line change:
from True to si_self in model_methods.
More over this change wouldn't break any existing code, since si_self would still evaluate to True.
What do you guys think?
The text was updated successfully, but these errors were encountered:
lehins
added a commit
to lehins/django-states2
that referenced
this issue
May 18, 2014
Great app, I was looking for something like it for a while. Thanks a whole bunch!
One small suggestion:
instead of returning True on
object.get_state_info().test_transition('transition_name', user)
it would probably better to return state_info instance, so the call can be chained:
instead of:
This way it is type consistent (
test_transition
never returnsFalse
anyhow), it is more DRY and by chaining calls like that we could also eliminate failed transition logs in a more concise way.I would submit a pull request myself, but it is literally a one line change:
from
True
tosi_self
in model_methods.More over this change wouldn't break any existing code, since
si_self
would still evaluate toTrue
.What do you guys think?
The text was updated successfully, but these errors were encountered: