Commits

Anonymous committed 18a68f4

Changed field sizes, tweaked FSM to act nicer in (some bits of) the admin

Comments (0)

Files changed (3)

statemachine/fields.py

 
 class FSM_StateField(models.Field):
     __metaclass__ = models.SubfieldBase
-
+    description = "Finite State Machine Field"
     def __init__(self, machine, default_choices_all=False, *args, **kwargs):
         self.__machine_class = machine
         self.default_choices_all = default_choices_all
             self._choices = self.exit_state_choices()
         return self.machine
 
+    def validate(self, value, model_instance):
+        print value.state
+
     def get_prep_value(self, value):
         return value
 
         return name
 
     def all_state_choices(self):
-        return [(name, pretty_name(name)) for name in self.machine.states.keys()]
+        return [(name, pretty_name(name)) for name, state in self.machine.states.items()]
 
     def exit_state_choices(self):
         state_choices = []

statemachine/fsm.py

         return self.__state
 
     def setstate(self, value):
-        raise FSM_NotAllowed("State is read only, please use execute() to change state")
+        raise FSM_NotAllowed("State is read only, please use change() to change state")
 
     state = property(getstate, setstate)
 

statemachine/models.py

     machine = generic.GenericForeignKey('machine_type', 'machine_id')
 
     # log of to / from, state info, date, user
-    from_state = models.CharField(max_length=25)
-    to_state = models.CharField(max_length=25)
+    from_state = models.CharField(max_length=50)
+    to_state = models.CharField(max_length=50)
     change_date = models.DateTimeField(auto_now=True)
     user = models.ForeignKey(User, null=True, blank=True)
 
     #optional notes
-    notes = models.CharField(max_length=200, null=True, blank=True)
+    notes = models.CharField(max_length=500, null=True, blank=True)
 
 class StateMachineWithHistory(models.Model):
     """