diff --git a/src/pretix/plugins/checkinlists/exporters.py b/src/pretix/plugins/checkinlists/exporters.py index 9c77001b54..b84d7cce7f 100644 --- a/src/pretix/plugins/checkinlists/exporters.py +++ b/src/pretix/plugins/checkinlists/exporters.py @@ -101,7 +101,7 @@ class BaseCheckinList(BaseExporter): last_checked_in=Subquery(cqs) ).prefetch_related( 'answers', 'answers__question', 'addon_to__answers', 'addon_to__answers__question' - ).select_related('order', 'item', 'variation', 'addon_to', 'order__invoice_address') + ).select_related('order', 'item', 'variation', 'addon_to', 'order__invoice_address', 'voucher') if not cl.all_products: qs = qs.filter(item__in=cl.limit_products.values_list('id', flat=True)) @@ -288,7 +288,8 @@ class CSVCheckinList(BaseCheckinList): label=_('CSV dialect'), choices=( ('default', 'Default'), - ('excel', 'Excel') + ('excel', 'Excel'), + ('semicolon', 'Semicolon'), ) ) return d @@ -297,6 +298,8 @@ class CSVCheckinList(BaseCheckinList): output = io.StringIO() if form_data.get('dialect', '-') in csv.list_dialects(): writer = csv.writer(output, dialect=form_data.get('dialect')) + elif form_data.get('dialect', '-') == "semicolon": + writer = csv.writer(output, dialect='excel', delimiter=';') else: writer = csv.writer(output, quoting=csv.QUOTE_NONNUMERIC, delimiter=",") @@ -335,6 +338,7 @@ class CSVCheckinList(BaseCheckinList): headers.append(str(q.question)) headers.append(_('Company')) + headers.append(_('Voucher code')) writer.writerow(headers) for op in qs: @@ -386,6 +390,7 @@ class CSVCheckinList(BaseCheckinList): row.append(acache.get(q.pk, '')) row.append(ia.company) + row.append(op.voucher.code if op.voucher else "") writer.writerow(row) return '{}_checkin.csv'.format(self.event.slug), 'text/csv', output.getvalue().encode("utf-8") diff --git a/src/tests/plugins/test_checkinlist.py b/src/tests/plugins/test_checkinlist.py index 1556d8696c..05ca4a7ed5 100644 --- a/src/tests/plugins/test_checkinlist.py +++ b/src/tests/plugins/test_checkinlist.py @@ -63,11 +63,11 @@ def test_csv_simple(event): }) assert clean(content.decode()) == clean(""""Order code","Attendee name","Attendee name: Title","Attendee name: First name","Attendee name: Middle name","Attendee name: Family name","Product","Price","Checked in","Secret", -"E-mail","Company" +"E-mail","Company","Voucher code" "FOO","Mr Peter A Jones","Mr","Peter","A","Jones","Ticket","23.00","","hutjztuxhkbtwnesv2suqv26k6ttytxx", -"dummy@dummy.test","" +"dummy@dummy.test","","" "FOO","Mrs Andrea J Zulu","Mrs","Andrea","J","Zulu","Ticket","13.00","","ggsngqtnmhx74jswjngw3fk8pfwz2a7k", -"dummy@dummy.test","" +"dummy@dummy.test","","" """) @@ -85,11 +85,11 @@ def test_csv_order_by_name_parts(event): # noqa }) assert clean(content.decode()) == clean(""""Order code","Attendee name","Attendee name: Title", "Attendee name: First name","Attendee name: Middle name","Attendee name: Family name","Product","Price", -"Checked in","Secret","E-mail","Company" +"Checked in","Secret","E-mail","Company","Voucher code" "FOO","Mrs Andrea J Zulu","Mrs","Andrea","J","Zulu","Ticket","13.00","","ggsngqtnmhx74jswjngw3fk8pfwz2a7k", -"dummy@dummy.test","" +"dummy@dummy.test","","" "FOO","Mr Peter A Jones","Mr","Peter","A","Jones","Ticket","23.00","","hutjztuxhkbtwnesv2suqv26k6ttytxx", -"dummy@dummy.test","" +"dummy@dummy.test","","" """) c = CSVCheckinList(event) _, _, content = c.render({ @@ -100,9 +100,9 @@ def test_csv_order_by_name_parts(event): # noqa }) assert clean(content.decode()) == clean(""""Order code","Attendee name","Attendee name: Title", "Attendee name: First name","Attendee name: Middle name","Attendee name: Family name","Product","Price", -"Checked in","Secret","E-mail","Company" +"Checked in","Secret","E-mail","Company","Voucher code" "FOO","Mr Peter A Jones","Mr","Peter","A","Jones","Ticket","23.00","","hutjztuxhkbtwnesv2suqv26k6ttytxx", -"dummy@dummy.test","" +"dummy@dummy.test","","" "FOO","Mrs Andrea J Zulu","Mrs","Andrea","J","Zulu","Ticket","13.00","","ggsngqtnmhx74jswjngw3fk8pfwz2a7k", -"dummy@dummy.test","" +"dummy@dummy.test","","" """)