[FIX] survey: validate_multiple_choice with comments allowed

When validating a multiple choice with comments allowed,
the comment was popped from answer_candidates and then
the condition to prevent answers with blank value always
triggered an error.

opw:707072
This commit is contained in:
Goffin Simon
2017-02-07 09:42:00 +01:00
parent 9ec95b2a68
commit 09237efa33
+1 -1
View File
@@ -637,7 +637,7 @@ class SurveyQuestion(models.Model):
if self.comments_allowed:
comment_answer = answer_candidates.pop(("%s_%s" % (answer_tag, 'comment')), '').strip()
# Preventing answers with blank value
if all([True if not answer.strip() else False for answer in answer_candidates.values()]):
if all([True if not answer.strip() else False for answer in answer_candidates.values()]) and answer_candidates:
errors.update({answer_tag: self.constr_error_msg})
# There is no answer neither comments (if comments count as answer)
if not answer_candidates and self.comment_count_as_answer and (not comment_flag or not comment_answer):