Allow to import orders (#1516)

* Allow to import orders

* seats, subevents

* Plugin support

* Add docs

* Warn about lack of quota handling

* Control interface test

* Test skeleton

* First tests for the impotr columns

* Add tests for all columns

* Fix question validation
This commit is contained in:
Raphael Michel
2019-12-11 11:44:06 +01:00
committed by GitHub
parent 1c99e01af9
commit 24b931e1c3
21 changed files with 2009 additions and 56 deletions

View File

@@ -1106,17 +1106,25 @@ class Question(LoggedModel):
if self.type == Question.TYPE_CHOICE:
try:
return self.options.get(pk=answer)
return self.options.get(Q(pk=answer) | Q(identifier=answer))
except:
raise ValidationError(_('Invalid option selected.'))
elif self.type == Question.TYPE_CHOICE_MULTIPLE:
try:
if isinstance(answer, str):
return list(self.options.filter(pk__in=answer.split(",")))
else:
return list(self.options.filter(pk__in=answer))
except:
if isinstance(answer, str):
l_ = list(self.options.filter(
Q(pk__in=[a for a in answer.split(",") if a.isdigit()]) |
Q(identifier__in=answer.split(","))
))
llen = len(answer.split(','))
else:
l_ = list(self.options.filter(
Q(pk__in=[a for a in answer if isinstance(a, int) or a.isdigit()]) |
Q(identifier__in=answer)
))
llen = len(answer)
if len(l_) != llen:
raise ValidationError(_('Invalid option selected.'))
return l_
elif self.type == Question.TYPE_BOOLEAN:
return answer in ('true', 'True', True)
elif self.type == Question.TYPE_NUMBER: