Skip to content

Commit 4def43f

Browse files
committed
fix: handling of unsaved workflows
1 parent 81a4cae commit 4def43f

File tree

1 file changed

+4
-2
lines changed
  • bread/contrib/workflows/models

1 file changed

+4
-2
lines changed

bread/contrib/workflows/models/base.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,10 +273,13 @@ def cancel(self, save=True):
273273
self.save()
274274

275275
def save(self, *args, **kwargs):
276-
self.update_workflow_state(runactions=True)
276+
if self.pk is not None:
277+
self.update_workflow_state(runactions=True)
277278
if not self.completed and not self.cancelled and self.done:
278279
self.completed = timezone.now()
279280
super().save(*args, **kwargs)
281+
self.update_workflow_state(runactions=True)
282+
super().save(*args, **kwargs)
280283

281284
def update_workflow_state(self, runactions=False):
282285
# don't do anything on the workflow after it has been cancelled
@@ -305,7 +308,6 @@ def update_workflow_state(self, runactions=False):
305308
setattr(self, node.name, actionresult)
306309
if isinstance(node, Decision):
307310
if any(n.done(self) for n, c in node.inputs):
308-
node.decide(self)
309311
decision = node.decide(self)
310312
if decision != getattr(self, node.name):
311313
state_changed = True

0 commit comments

Comments
 (0)