mirror of
https://github.com/pretix/pretix.git
synced 2026-05-06 15:24:02 +00:00
Move bulk_create logic during bulk voucher creation
This commit is contained in:
@@ -388,4 +388,9 @@ class VoucherBulkForm(VoucherForm):
|
||||
del data['codes']
|
||||
objs.append(obj)
|
||||
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
|
||||
|
||||
@@ -320,11 +320,9 @@ class VoucherBulkCreate(EventPermissionRequiredMixin, CreateView):
|
||||
@transaction.atomic
|
||||
def form_valid(self, form):
|
||||
log_entries = []
|
||||
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
|
||||
objs = form.save(self.request.event)
|
||||
voucherids = []
|
||||
for v in self.request.event.vouchers.filter(code__in=form.cleaned_data['codes']):
|
||||
for v in objs:
|
||||
log_entries.append(
|
||||
v.log_action('pretix.voucher.added', data=form.cleaned_data, user=self.request.user, save=False)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user