This fixes 2 issues with setting boolean defaults

- If the default was False, we failed an early test and returned None. We now only return None if default is None
 - We have a better test for deciding if the default value we return should be True or False. We used to return True if the value was the string 'false'.
This commit is contained in:
mike cullerton 2021-02-03 09:50:16 -05:00
parent cccb722e07
commit b090e31e00
1 changed files with 7 additions and 2 deletions

View File

@ -251,7 +251,9 @@ class WorkflowService(object):
default = result
# If no default exists, return None
if not default: return None
# Note: if default is False, we don't want to execute this code
if default is None:
return None
if field.type == "enum" and not has_lookup:
default_option = next((obj for obj in field.options if obj.id == default), None)
@ -278,7 +280,10 @@ class WorkflowService(object):
elif field.type == "long":
return int(default)
elif field.type == 'boolean':
return bool(default)
default = str(default).lower()
if default == 'true' or default == 't':
return True
return False
else:
return default