forked from CGM_Public/pretix_original
Move bulk_create logic during bulk voucher creation
This commit is contained in:
@@ -388,4 +388,9 @@ class VoucherBulkForm(VoucherForm):
|
|||||||
del data['codes']
|
del data['codes']
|
||||||
objs.append(obj)
|
objs.append(obj)
|
||||||
Voucher.objects.bulk_create(objs)
|
Voucher.objects.bulk_create(objs)
|
||||||
|
objs = []
|
||||||
|
for v in event.vouchers.filter(code__in=self.cleaned_data['codes']):
|
||||||
|
# We need to query them again as bulk_create does not fill in .pk values on databases
|
||||||
|
# other than PostgreSQL
|
||||||
|
objs.append(v)
|
||||||
return objs
|
return objs
|
||||||
|
|||||||
@@ -320,11 +320,9 @@ class VoucherBulkCreate(EventPermissionRequiredMixin, CreateView):
|
|||||||
@transaction.atomic
|
@transaction.atomic
|
||||||
def form_valid(self, form):
|
def form_valid(self, form):
|
||||||
log_entries = []
|
log_entries = []
|
||||||
form.save(self.request.event)
|
objs = form.save(self.request.event)
|
||||||
# We need to query them again as form.save() uses bulk_create which does not fill in .pk values on databases
|
|
||||||
# other than PostgreSQL
|
|
||||||
voucherids = []
|
voucherids = []
|
||||||
for v in self.request.event.vouchers.filter(code__in=form.cleaned_data['codes']):
|
for v in objs:
|
||||||
log_entries.append(
|
log_entries.append(
|
||||||
v.log_action('pretix.voucher.added', data=form.cleaned_data, user=self.request.user, save=False)
|
v.log_action('pretix.voucher.added', data=form.cleaned_data, user=self.request.user, save=False)
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user