Fix bug where API assumed survey choices were list

Applies to both single-select and multi-select type questions.
UI sends choices in the form of text with line breaks
separating the options.
Customer complained about empty string erronously sent by
the UI being passed to playbook, which is a component of this.
This commit is contained in:
AlanCoding
2017-04-06 17:32:08 -04:00
parent 915eccd982
commit b9c45ed54a
3 changed files with 51 additions and 8 deletions

View File

@@ -135,13 +135,15 @@ def create_survey_spec(variables=None, default_type='integer', required=True):
argument specifying variable name(s)
'''
if isinstance(variables, list):
name = "%s survey" % variables[0]
description = "A survey that starts with %s." % variables[0]
vars_list = variables
else:
name = "%s survey" % variables
description = "A survey about %s." % variables
vars_list = [variables]
if isinstance(variables[0], basestring):
slogan = variables[0]
else:
slogan = variables[0].get('question_name', 'something')
name = "%s survey" % slogan
description = "A survey that asks about %s." % slogan
spec = []
index = 0