From 434144d2764d41193e95504eb82ecd2180f35939 Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Tue, 14 Oct 2014 13:37:52 -0400 Subject: [PATCH] Make min and max optional in the fields they are used in --- awx/main/models/jobs.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/awx/main/models/jobs.py b/awx/main/models/jobs.py index c82eb6f2e5..53b9c40048 100644 --- a/awx/main/models/jobs.py +++ b/awx/main/models/jobs.py @@ -243,19 +243,19 @@ class JobTemplate(UnifiedJobTemplate, JobOptions): errors.append("'%s' value missing" % survey_element['variable']) elif survey_element['type'] in ["textarea", "text"]: if survey_element['variable'] in data: - if survey_element['min'] != "" and len(data[survey_element['variable']]) < survey_element['min']: + if 'min' in survey_element and survey_element['min'] != "" and len(data[survey_element['variable']]) < survey_element['min']: errors.append("'%s' value %s is too small (must be at least %s)" % (survey_element['variable'], data[survey_element['variable']], survey_element['min'])) - if survey_element['max'] != "" and len(data[survey_element['variable']]) > survey_element['max']: + if 'max' in survey_element and survey_element['max'] != "" and len(data[survey_element['variable']]) > survey_element['max']: errors.append("'%s' value %s is too large (must be no more than%s)" % (survey_element['variable'], data[survey_element['variable']], survey_element['max'])) elif survey_element['type'] == 'integer': if survey_element['variable'] in data: - if survey_element['min'] != "" and survey_element['variable'] in data and \ + if 'min' in survey_element and survey_element['min'] != "" and survey_element['variable'] in data and \ data[survey_element['variable']] < survey_element['min']: errors.append("'%s' value %s is too small (must be at least %s)" % (survey_element['variable'], data[survey_element['variable']], survey_element['min'])) - if survey_element['max'] != "" and survey_element['variable'] in data and \ + if 'max' in survey_element and survey_element['max'] != "" and survey_element['variable'] in data and \ data[survey_element['variable']] > survey_element['max']: errors.append("'%s' value %s is too large (must be no more than%s)" % (survey_element['variable'], data[survey_element['variable']], survey_element['max'])) @@ -264,10 +264,10 @@ class JobTemplate(UnifiedJobTemplate, JobOptions): survey_element['variable'])) elif survey_element['type'] == 'float': if survey_element['variable'] in data: - if survey_element['min'] != "" and data[survey_element['variable']] < survey_element['min']: + if 'min' in survey_element and survey_element['min'] != "" and data[survey_element['variable']] < survey_element['min']: errors.append("'%s' value %s is too small (must be at least %s)" % (survey_element['variable'], data[survey_element['variable']], survey_element['min'])) - if survey_element['max'] != "" and data[survey_element['variable']] > survey_element['max']: + if 'max' in survey_element and survey_element['max'] != "" and data[survey_element['variable']] > survey_element['max']: errors.append("'%s' value %s is too large (must be no more than%s)" % (survey_element['variable'], data[survey_element['variable']], survey_element['max'])) if type(data[survey_element['variable']]) != float: