Cleaning up my smell. A task should only have default_value *or* value_expresion, not both.

This commit is contained in:
mike cullerton 2021-01-27 10:21:13 -05:00
parent 1ee6a11d46
commit 81e55b6055
1 changed files with 6 additions and 5 deletions

View File

@ -153,11 +153,12 @@ class WorkflowService(object):
if WorkflowService.evaluate_property(Task.FIELD_PROP_HIDE_EXPRESSION, field, task):
continue
# If we set the default with value_expression
if field.has_property(Task.FIELD_PROP_VALUE_EXPRESSION):
form_data[field.id] = WorkflowService.get_default_value(field, task)
# If there is a default value, set it.
elif hasattr(field, 'default_value') and field.default_value:
# A task should only have default_value **or** value expression, not both.
if field.has_property(Task.FIELD_PROP_VALUE_EXPRESSION) and (hasattr(field, 'default_value') and field.default_value):
raise ApiError(code='default value and value_expression',
message='This task has both a default_value and value_expression. Please fix this to only have one or the other.')
# If we have a default_value or value_expression, try to set the default
if field.has_property(Task.FIELD_PROP_VALUE_EXPRESSION) or (hasattr(field, 'default_value') and field.default_value):
form_data[field.id] = WorkflowService.get_default_value(field, task)
# If we are only populating required fields, and this isn't required. stop here.