Commits

Ian George committed 7d122b2

Hacked option to change the history date when saving

Comments (0)

Files changed (1)

statemachine/models.py

         self._opening_state = self.status.state
 
     def save(self, user, notes='', *args, **kwargs):
+        change_date = kwargs.pop('change_date', None)
         super(StateMachineWithHistory, self).save(*args, **kwargs)
 
         if self.status.state != self._opening_state:
             s.machine = self
             s.from_state = self._opening_state
             s.to_state = self.status.state
+            if change_date:
+                s._meta.fields[5].auto_now = False
+                s.change_date = change_date
             s.user = user
             s.notes = notes
             s.save()
 
+            if change_date:
+                s._meta.fields[5].auto_now = True
+
     class Meta:
         abstract = True