mirror of
https://github.com/pretix/pretix.git
synced 2026-05-09 15:54:03 +00:00
Co-authored-by: Raphael Michel <michel@rami.io>
This commit is contained in:
@@ -550,7 +550,8 @@ class BaseQuestionsForm(forms.Form):
|
|||||||
|
|
||||||
if not self.all_optional:
|
if not self.all_optional:
|
||||||
for q in question_cache.values():
|
for q in question_cache.values():
|
||||||
if question_is_required(q) and not d.get('question_%d' % q.pk):
|
answer = d.get('question_%d' % q.pk)
|
||||||
|
if question_is_required(q) and not answer and answer != 0:
|
||||||
raise ValidationError({'question_%d' % q.pk: [_('This field is required')]})
|
raise ValidationError({'question_%d' % q.pk: [_('This field is required')]})
|
||||||
|
|
||||||
return d
|
return d
|
||||||
|
|||||||
@@ -570,7 +570,7 @@ class QuestionsStep(QuestionsViewMixin, CartMixin, TemplateFlowStep):
|
|||||||
)
|
)
|
||||||
|
|
||||||
for q in cp.item.questions_to_ask:
|
for q in cp.item.questions_to_ask:
|
||||||
if question_is_required(q) and not answ.get(q.id):
|
if question_is_required(q) and q.id not in answ:
|
||||||
if warn:
|
if warn:
|
||||||
messages.warning(request, _('Please fill in answers to all required questions.'))
|
messages.warning(request, _('Please fill in answers to all required questions.'))
|
||||||
return False
|
return False
|
||||||
|
|||||||
@@ -2660,7 +2660,7 @@ class QuestionsTestCase(BaseCheckoutTestCase, TestCase):
|
|||||||
# Corrected request
|
# Corrected request
|
||||||
response = self.client.post('/%s/%s/checkout/questions/' % (self.orga.slug, self.event.slug), {
|
response = self.client.post('/%s/%s/checkout/questions/' % (self.orga.slug, self.event.slug), {
|
||||||
'%s-question_%s' % (cr1.id, q1.id): '42',
|
'%s-question_%s' % (cr1.id, q1.id): '42',
|
||||||
'%s-question_%s' % (cr2.id, q1.id): '23',
|
'%s-question_%s' % (cr2.id, q1.id): '0',
|
||||||
'%s-question_%s' % (cr1.id, q2.id): 'Internet',
|
'%s-question_%s' % (cr1.id, q2.id): 'Internet',
|
||||||
'%s-question_%s' % (cr2.id, q2.id): '',
|
'%s-question_%s' % (cr2.id, q2.id): '',
|
||||||
'email': 'admin@localhost'
|
'email': 'admin@localhost'
|
||||||
@@ -2750,6 +2750,7 @@ class QuestionsTestCase(BaseCheckoutTestCase, TestCase):
|
|||||||
event=self.event, question='Why not?', type=Question.TYPE_TEXT,
|
event=self.event, question='Why not?', type=Question.TYPE_TEXT,
|
||||||
required=True, dependency_question=self.q3, dependency_values=['False']
|
required=True, dependency_question=self.q3, dependency_values=['False']
|
||||||
)
|
)
|
||||||
|
|
||||||
self.ticket.questions.add(self.q1)
|
self.ticket.questions.add(self.q1)
|
||||||
self.ticket.questions.add(self.q2a)
|
self.ticket.questions.add(self.q2a)
|
||||||
self.ticket.questions.add(self.q2b)
|
self.ticket.questions.add(self.q2b)
|
||||||
|
|||||||
Reference in New Issue
Block a user