mirror of
https://github.com/pretix/pretix.git
synced 2026-04-29 00:12:38 +00:00
Fix mass-creation of vouchers on MySQL
This commit is contained in:
@@ -434,7 +434,8 @@ class VoucherBulkCreate(EventPermissionRequiredMixin, AsyncFormView):
|
|||||||
|
|
||||||
def process_batch(batch_vouchers, voucherids):
|
def process_batch(batch_vouchers, voucherids):
|
||||||
Voucher.objects.bulk_create(batch_vouchers)
|
Voucher.objects.bulk_create(batch_vouchers)
|
||||||
if not connection.features.can_return_rows_from_bulk_insert:
|
if not connection.features.can_return_rows_from_bulk_insert or True:
|
||||||
|
batch_vouchers.clear()
|
||||||
batch_vouchers = list(self.request.event.vouchers.filter(code__in=[v.code for v in batch_vouchers]))
|
batch_vouchers = list(self.request.event.vouchers.filter(code__in=[v.code for v in batch_vouchers]))
|
||||||
|
|
||||||
log_entries = []
|
log_entries = []
|
||||||
@@ -460,7 +461,7 @@ class VoucherBulkCreate(EventPermissionRequiredMixin, AsyncFormView):
|
|||||||
|
|
||||||
batch_vouchers = []
|
batch_vouchers = []
|
||||||
for code in form.cleaned_data['codes']:
|
for code in form.cleaned_data['codes']:
|
||||||
if len(batch_vouchers) > batch_size:
|
if len(batch_vouchers) >= batch_size:
|
||||||
process_batch(batch_vouchers, voucherids)
|
process_batch(batch_vouchers, voucherids)
|
||||||
|
|
||||||
obj = modelcopy(form.instance, code=None)
|
obj = modelcopy(form.instance, code=None)
|
||||||
|
|||||||
Reference in New Issue
Block a user