added in parsing for multiple choice and multiselect, which either takes a string, splits it up, and then eliminates any extra newlines, or just accepts alist. Extra newlines are sanitized out.

Signed-off-by: Rebeccah <rhunter@redhat.com>
This commit is contained in:
Rebeccah
2019-09-30 17:16:08 -04:00
parent ff67d65065
commit 7efacb69aa
2 changed files with 30 additions and 6 deletions

View File

@@ -253,7 +253,7 @@ class SurveyJobTemplateMixin(models.Model):
else:
choice_list = copy(survey_element['choices'])
if isinstance(choice_list, str):
choice_list = choice_list.split('\n')
choice_list = [choice for choice in choice_list.splitlines() if choice.strip() != '']
for val in data[survey_element['variable']]:
if val not in choice_list:
errors.append("Value %s for '%s' expected to be one of %s." % (val, survey_element['variable'],
@@ -261,7 +261,7 @@ class SurveyJobTemplateMixin(models.Model):
elif survey_element['type'] == 'multiplechoice':
choice_list = copy(survey_element['choices'])
if isinstance(choice_list, str):
choice_list = choice_list.split('\n')
choice_list = [choice for choice in choice_list.splitlines() if choice.strip() != '']
if survey_element['variable'] in data:
if data[survey_element['variable']] not in choice_list:
errors.append("Value %s for '%s' expected to be one of %s." % (data[survey_element['variable']],