Webhooks: Add vouchers (Z#23203072) (#5360)

* Webhooks: Add vouchers (Z#23203072)

This also requires more consistent usage of webhook types to avoid
vouchers not being known to the external system.

* Update src/pretix/api/webhooks.py

Co-authored-by: luelista <weller@rami.io>

* Fix shredder test

---------

Co-authored-by: luelista <weller@rami.io>
This commit is contained in:
Raphael Michel
2025-08-19 13:04:22 +02:00
committed by GitHub
parent 7cdccc7d8e
commit 0cc8e59bb0
7 changed files with 59 additions and 12 deletions

View File

@@ -380,7 +380,7 @@ class VoucherCreate(EventPermissionRequiredMixin, CreateView):
messages.success(self.request, mark_safe(_('The new voucher has been created: {code}').format(
code=format_html('<a href="{url}">{code}</a>', url=url, code=self.object.code)
)))
form.instance.log_action('pretix.voucher.added', data=dict(form.cleaned_data), user=self.request.user)
form.instance.log_action('pretix.voucher.added', data={**dict(form.cleaned_data), "source": "control"}, user=self.request.user)
return ret
@transaction.atomic
@@ -475,7 +475,7 @@ class VoucherBulkCreate(EventPermissionRequiredMixin, AsyncFormView):
data['bulk'] = True
del data['codes']
log_entries.append(
v.log_action('pretix.voucher.added', data=data, user=self.request.user, save=False)
v.log_action('pretix.voucher.added', data={**data, "source": "control_bulk"}, user=self.request.user, save=False)
)
LogEntry.bulk_create_and_postprocess(log_entries)
form.post_bulk_save(batch_vouchers)