Validate the state completion value before saving
Thanks to Manoel Brunnen (@mbru) for the report and debug information. GitLab issue #557. Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
@@ -208,6 +208,19 @@ class WorkflowState(models.Model):
|
||||
).distinct()
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
# Solve issue #557 "Break workflows with invalid input"
|
||||
# without using a migration.
|
||||
# Remove blank=True, remove this, and create a migration in the next
|
||||
# minor version.
|
||||
|
||||
try:
|
||||
self.completion = int(self.completion)
|
||||
except (TypeError, ValueError):
|
||||
self.completion = 0
|
||||
|
||||
#if not self.completion:
|
||||
# self.completion = 0
|
||||
|
||||
if self.initial:
|
||||
self.workflow.states.all().update(initial=False)
|
||||
return super(WorkflowState, self).save(*args, **kwargs)
|
||||
|
||||
Reference in New Issue
Block a user