forked from CGM_Public/pretix_original
Add option to export multiple choice answers in orderlists grouped (#1898)
This commit is contained in:
committed by
GitHub
parent
f97c97e661
commit
e2461ab475
@@ -59,6 +59,12 @@ class OrderListExporter(MultiSheetListExporter):
|
|||||||
initial=False,
|
initial=False,
|
||||||
required=False
|
required=False
|
||||||
)),
|
)),
|
||||||
|
('group_multiple_choice',
|
||||||
|
forms.BooleanField(
|
||||||
|
label=_('Show multiple choice answers grouped in one colum'),
|
||||||
|
initial=False,
|
||||||
|
required=False
|
||||||
|
)),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -449,9 +455,14 @@ class OrderListExporter(MultiSheetListExporter):
|
|||||||
for q in questions:
|
for q in questions:
|
||||||
if q.type == Question.TYPE_CHOICE_MULTIPLE:
|
if q.type == Question.TYPE_CHOICE_MULTIPLE:
|
||||||
options[q.pk] = []
|
options[q.pk] = []
|
||||||
for o in q.options.all():
|
if form_data['group_multiple_choice']:
|
||||||
headers.append(str(q.question) + ' – ' + str(o.answer))
|
for o in q.options.all():
|
||||||
options[q.pk].append(o)
|
options[q.pk].append(o)
|
||||||
|
headers.append(str(q.question))
|
||||||
|
else:
|
||||||
|
for o in q.options.all():
|
||||||
|
headers.append(str(q.question) + ' – ' + str(o.answer))
|
||||||
|
options[q.pk].append(o)
|
||||||
else:
|
else:
|
||||||
headers.append(str(q.question))
|
headers.append(str(q.question))
|
||||||
headers += [
|
headers += [
|
||||||
@@ -551,8 +562,11 @@ class OrderListExporter(MultiSheetListExporter):
|
|||||||
acache[a.question_id] = str(a)
|
acache[a.question_id] = str(a)
|
||||||
for q in questions:
|
for q in questions:
|
||||||
if q.type == Question.TYPE_CHOICE_MULTIPLE:
|
if q.type == Question.TYPE_CHOICE_MULTIPLE:
|
||||||
for o in options[q.pk]:
|
if form_data['group_multiple_choice']:
|
||||||
row.append(_('Yes') if o.pk in acache.get(q.pk, set()) else _('No'))
|
row.append(", ".join(str(o.answer) for o in options[q.pk] if o.pk in acache.get(q.pk, set())))
|
||||||
|
else:
|
||||||
|
for o in options[q.pk]:
|
||||||
|
row.append(_('Yes') if o.pk in acache.get(q.pk, set()) else _('No'))
|
||||||
else:
|
else:
|
||||||
row.append(acache.get(q.pk, ''))
|
row.append(acache.get(q.pk, ''))
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,10 @@ SAMPLE_EXPORTER_CONFIG = {
|
|||||||
"name": "include_payment_amounts",
|
"name": "include_payment_amounts",
|
||||||
"required": False
|
"required": False
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "group_multiple_choice",
|
||||||
|
"required": False
|
||||||
|
},
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user