mirror of
https://github.com/pretix/pretix.git
synced 2026-05-11 16:13:59 +00:00
Order data export: Split multiple choice questions in multiple columns
This commit is contained in:
@@ -264,7 +264,7 @@ class OrderListExporter(MultiSheetListExporter):
|
|||||||
'order', 'order__invoice_address', 'item', 'variation',
|
'order', 'order__invoice_address', 'item', 'variation',
|
||||||
'voucher', 'tax_rule'
|
'voucher', 'tax_rule'
|
||||||
).prefetch_related(
|
).prefetch_related(
|
||||||
'answers', 'answers__question'
|
'answers', 'answers__question', 'answers__options'
|
||||||
)
|
)
|
||||||
if form_data['paid_only']:
|
if form_data['paid_only']:
|
||||||
qs = qs.filter(order__status=Order.STATUS_PAID)
|
qs = qs.filter(order__status=Order.STATUS_PAID)
|
||||||
@@ -299,8 +299,15 @@ class OrderListExporter(MultiSheetListExporter):
|
|||||||
_('Pseudonymization ID'),
|
_('Pseudonymization ID'),
|
||||||
]
|
]
|
||||||
questions = list(self.event.questions.all())
|
questions = list(self.event.questions.all())
|
||||||
|
options = {}
|
||||||
for q in questions:
|
for q in questions:
|
||||||
headers.append(str(q.question))
|
if q.type == Question.TYPE_CHOICE_MULTIPLE:
|
||||||
|
options[q.pk] = []
|
||||||
|
for o in q.options.all():
|
||||||
|
headers.append(str(q.question) + ' – ' + str(o.answer))
|
||||||
|
options[q.pk].append(o)
|
||||||
|
else:
|
||||||
|
headers.append(str(q.question))
|
||||||
headers += [
|
headers += [
|
||||||
_('Company'),
|
_('Company'),
|
||||||
_('Invoice address name'),
|
_('Invoice address name'),
|
||||||
@@ -354,12 +361,19 @@ class OrderListExporter(MultiSheetListExporter):
|
|||||||
for a in op.answers.all():
|
for a in op.answers.all():
|
||||||
# We do not want to localize Date, Time and Datetime question answers, as those can lead
|
# We do not want to localize Date, Time and Datetime question answers, as those can lead
|
||||||
# to difficulties parsing the data (for example 2019-02-01 may become Février, 2019 01 in French).
|
# to difficulties parsing the data (for example 2019-02-01 may become Février, 2019 01 in French).
|
||||||
if a.question.type in Question.UNLOCALIZED_TYPES:
|
if a.question.type == Question.TYPE_CHOICE_MULTIPLE:
|
||||||
|
acache[a.question_id] = set(o.pk for o in a.options.all())
|
||||||
|
elif a.question.type in Question.UNLOCALIZED_TYPES:
|
||||||
acache[a.question_id] = a.answer
|
acache[a.question_id] = a.answer
|
||||||
else:
|
else:
|
||||||
acache[a.question_id] = str(a)
|
acache[a.question_id] = str(a)
|
||||||
for q in questions:
|
for q in questions:
|
||||||
row.append(acache.get(q.pk, ''))
|
if q.type == Question.TYPE_CHOICE_MULTIPLE:
|
||||||
|
for o in options[q.pk]:
|
||||||
|
row.append(_('Yes') if o.pk in acache.get(q.pk, set()) else _('No'))
|
||||||
|
else:
|
||||||
|
row.append(acache.get(q.pk, ''))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
row += [
|
row += [
|
||||||
order.invoice_address.company,
|
order.invoice_address.company,
|
||||||
|
|||||||
Reference in New Issue
Block a user