Skip to content

Commit e3e8c18

Browse files
Gabriel MonroyMatthew Fisher
authored andcommitted
fix(fsm): save state transitions as they happen
1 parent ecf167d commit e3e8c18

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

controller/api/models.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from django.db.models.signals import post_save
2020
from django.utils.encoding import python_2_unicode_compatible
2121
from django_fsm import FSMField, transition
22+
from django_fsm.signals import post_transition
2223
from json_field.fields import JSONField
2324

2425
from api import fields, tasks
@@ -536,6 +537,13 @@ def _etcd_purge_user(**kwargs):
536537
post_save.connect(_log_release_created, sender=Release, dispatch_uid='api.models')
537538
post_save.connect(_log_config_updated, sender=Config, dispatch_uid='api.models')
538539

540+
541+
# save FSM transitions as they happen
542+
def _save_transition(**kwargs):
543+
kwargs['instance'].save()
544+
545+
post_transition.connect(_save_transition)
546+
539547
# wire up etcd publishing if we can connect
540548
try:
541549
_etcd_client = etcd.Client(host=settings.ETCD_HOST, port=int(settings.ETCD_PORT))

0 commit comments

Comments
 (0)