mirror of
https://github.com/pretix/pretix.git
synced 2026-05-06 15:24:02 +00:00
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:
@@ -43,7 +43,7 @@ from django.forms import formset_factory, inlineformset_factory
|
||||
from django.forms.utils import ErrorDict
|
||||
from django.urls import reverse
|
||||
from django.utils.crypto import get_random_string
|
||||
from django.utils.html import conditional_escape
|
||||
from django.utils.html import conditional_escape, format_html
|
||||
from django.utils.safestring import mark_safe
|
||||
from django.utils.translation import gettext_lazy as _, pgettext_lazy
|
||||
from django_scopes.forms import SafeModelChoiceField
|
||||
@@ -695,7 +695,9 @@ class WebHookForm(forms.ModelForm):
|
||||
self.fields['events'].choices = [
|
||||
(
|
||||
a.action_type,
|
||||
mark_safe('{} – <code>{}</code>'.format(a.verbose_name, a.action_type))
|
||||
format_html('{} – <code>{}</code><br><span class="text-muted">{}</span>', a.verbose_name, a.action_type, a.help_text)
|
||||
if a.help_text else
|
||||
format_html('{} – <code>{}</code>', a.verbose_name, a.action_type)
|
||||
) for a in get_all_webhook_events().values()
|
||||
]
|
||||
if self.instance and self.instance.pk:
|
||||
|
||||
@@ -571,11 +571,11 @@ class CoreOrderLogEntryType(OrderLogEntryType):
|
||||
@log_entry_types.new_from_dict({
|
||||
'pretix.voucher.added': _('The voucher has been created.'),
|
||||
'pretix.voucher.sent': _('The voucher has been sent to {recipient}.'),
|
||||
'pretix.voucher.added.waitinglist': _('The voucher has been created and sent to a person on the waiting list.'),
|
||||
'pretix.voucher.expired.waitinglist': _(
|
||||
'The voucher has been set to expire because the recipient removed themselves from the waiting list.'),
|
||||
'pretix.voucher.changed': _('The voucher has been changed.'),
|
||||
'pretix.voucher.deleted': _('The voucher has been deleted.'),
|
||||
'pretix.voucher.added.waitinglist': _('The voucher has been sent to {email} through the waiting list.'),
|
||||
})
|
||||
class CoreVoucherLogEntryType(VoucherLogEntryType):
|
||||
pass
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user