Order creation API: Fix possible crash (PRETIXEU-4MS)

This commit is contained in:
Raphael Michel
2021-06-22 11:00:21 +02:00
parent fa8552e86f
commit 60c3b76ee9

View File

@@ -199,7 +199,9 @@ class AnswerSerializer(I18nAwareModelSerializer):
return data
def validate(self, data):
if data.get('question').type == Question.TYPE_FILE:
if not data.get('question'):
raise ValidationError('Question not specified.')
elif data.get('question').type == Question.TYPE_FILE:
return self._handle_file_upload(data)
elif data.get('question').type in (Question.TYPE_CHOICE, Question.TYPE_CHOICE_MULTIPLE):
if not data.get('options'):