From 81e55b6055020433da15e1fcb868c90247fb14d5 Mon Sep 17 00:00:00 2001 From: mike cullerton Date: Wed, 27 Jan 2021 10:21:13 -0500 Subject: [PATCH] Cleaning up my smell. A task should only have default_value *or* value_expresion, not both. --- crc/services/workflow_service.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/crc/services/workflow_service.py b/crc/services/workflow_service.py index ecc3770c..96234a2b 100644 --- a/crc/services/workflow_service.py +++ b/crc/services/workflow_service.py @@ -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.