forked from CGM_Public/pretix_original
Voucher bulk creation: Fix vouchers being created in wrong order
This commit is contained in:
@@ -35,7 +35,7 @@ def vouchers_send(event: Event, vouchers: list, subject: str, message: str, reci
|
|||||||
for ir, r in enumerate(recipients):
|
for ir, r in enumerate(recipients):
|
||||||
voucher_list = []
|
voucher_list = []
|
||||||
for i in range(r['number']):
|
for i in range(r['number']):
|
||||||
voucher_list.append(vouchers.pop())
|
voucher_list.append(vouchers.pop(0))
|
||||||
with language(event.settings.locale):
|
with language(event.settings.locale):
|
||||||
email_context = get_email_context(event=event, name=r.get('name') or '',
|
email_context = get_email_context(event=event, name=r.get('name') or '',
|
||||||
voucher_list=[v.code for v in voucher_list])
|
voucher_list=[v.code for v in voucher_list])
|
||||||
|
|||||||
@@ -521,13 +521,11 @@ class VoucherFormTest(SoupTestMixin, TransactionTestCase):
|
|||||||
'send': 'on',
|
'send': 'on',
|
||||||
'send_subject': 'Your voucher',
|
'send_subject': 'Your voucher',
|
||||||
'send_message': 'Voucher list: {voucher_list}',
|
'send_message': 'Voucher list: {voucher_list}',
|
||||||
'send_recipients': 'foo@example.com\nfoo@example.net'
|
'send_recipients': 'foo@example.com\nbar@example.net'
|
||||||
})
|
})
|
||||||
assert len(djmail.outbox) == 2
|
assert len(djmail.outbox) == 2
|
||||||
assert len([m for m in djmail.outbox if m.to == ['foo@example.com']]) == 1
|
assert len([m for m in djmail.outbox if 'ABCDE' in m.body and m.to == ['foo@example.com']]) == 1
|
||||||
assert len([m for m in djmail.outbox if m.to == ['foo@example.net']]) == 1
|
assert len([m for m in djmail.outbox if 'DEFGH' in m.body and m.to == ['bar@example.net']]) == 1
|
||||||
assert len([m for m in djmail.outbox if 'ABCDE' in m.body]) == 1
|
|
||||||
assert len([m for m in djmail.outbox if 'DEFGH' in m.body]) == 1
|
|
||||||
|
|
||||||
def test_create_bulk_send_csv(self):
|
def test_create_bulk_send_csv(self):
|
||||||
self._create_bulk_vouchers({
|
self._create_bulk_vouchers({
|
||||||
|
|||||||
Reference in New Issue
Block a user