forked from CGM_Public/pretix_original
Add webhooks for changes to items (#3087)
This commit is contained in:
@@ -56,6 +56,7 @@ The following values for ``action_types`` are valid with pretix core:
|
|||||||
* ``pretix.subevent.added``
|
* ``pretix.subevent.added``
|
||||||
* ``pretix.subevent.changed``
|
* ``pretix.subevent.changed``
|
||||||
* ``pretix.subevent.deleted``
|
* ``pretix.subevent.deleted``
|
||||||
|
* ``pretix.event.item.*``
|
||||||
* ``pretix.event.live.activated``
|
* ``pretix.event.live.activated``
|
||||||
* ``pretix.event.live.deactivated``
|
* ``pretix.event.live.deactivated``
|
||||||
* ``pretix.event.testmode.activated``
|
* ``pretix.event.testmode.activated``
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ def get_all_webhook_events():
|
|||||||
return types
|
return types
|
||||||
|
|
||||||
|
|
||||||
class ParametrizedOrderWebhookEvent(WebhookEvent):
|
class ParametrizedWebhookEvent(WebhookEvent):
|
||||||
def __init__(self, action_type, verbose_name):
|
def __init__(self, action_type, verbose_name):
|
||||||
self._action_type = action_type
|
self._action_type = action_type
|
||||||
self._verbose_name = verbose_name
|
self._verbose_name = verbose_name
|
||||||
@@ -110,6 +110,8 @@ class ParametrizedOrderWebhookEvent(WebhookEvent):
|
|||||||
def verbose_name(self):
|
def verbose_name(self):
|
||||||
return self._verbose_name
|
return self._verbose_name
|
||||||
|
|
||||||
|
|
||||||
|
class ParametrizedOrderWebhookEvent(ParametrizedWebhookEvent):
|
||||||
def build_payload(self, logentry: LogEntry):
|
def build_payload(self, logentry: LogEntry):
|
||||||
order = logentry.content_object
|
order = logentry.content_object
|
||||||
if not order:
|
if not order:
|
||||||
@@ -124,19 +126,7 @@ class ParametrizedOrderWebhookEvent(WebhookEvent):
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class ParametrizedEventWebhookEvent(WebhookEvent):
|
class ParametrizedEventWebhookEvent(ParametrizedWebhookEvent):
|
||||||
def __init__(self, action_type, verbose_name):
|
|
||||||
self._action_type = action_type
|
|
||||||
self._verbose_name = verbose_name
|
|
||||||
super().__init__()
|
|
||||||
|
|
||||||
@property
|
|
||||||
def action_type(self):
|
|
||||||
return self._action_type
|
|
||||||
|
|
||||||
@property
|
|
||||||
def verbose_name(self):
|
|
||||||
return self._verbose_name
|
|
||||||
|
|
||||||
def build_payload(self, logentry: LogEntry):
|
def build_payload(self, logentry: LogEntry):
|
||||||
if logentry.action_type == 'pretix.event.deleted':
|
if logentry.action_type == 'pretix.event.deleted':
|
||||||
@@ -160,19 +150,7 @@ class ParametrizedEventWebhookEvent(WebhookEvent):
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class ParametrizedSubEventWebhookEvent(WebhookEvent):
|
class ParametrizedSubEventWebhookEvent(ParametrizedWebhookEvent):
|
||||||
def __init__(self, action_type, verbose_name):
|
|
||||||
self._action_type = action_type
|
|
||||||
self._verbose_name = verbose_name
|
|
||||||
super().__init__()
|
|
||||||
|
|
||||||
@property
|
|
||||||
def action_type(self):
|
|
||||||
return self._action_type
|
|
||||||
|
|
||||||
@property
|
|
||||||
def verbose_name(self):
|
|
||||||
return self._verbose_name
|
|
||||||
|
|
||||||
def build_payload(self, logentry: LogEntry):
|
def build_payload(self, logentry: LogEntry):
|
||||||
# do not use content_object, this is also called in deletion
|
# do not use content_object, this is also called in deletion
|
||||||
@@ -185,6 +163,19 @@ class ParametrizedSubEventWebhookEvent(WebhookEvent):
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class ParametrizedItemWebhookEvent(ParametrizedWebhookEvent):
|
||||||
|
|
||||||
|
def build_payload(self, logentry: LogEntry):
|
||||||
|
# do not use content_object, this is also called in deletion
|
||||||
|
return {
|
||||||
|
'notification_id': logentry.pk,
|
||||||
|
'organizer': logentry.event.organizer.slug,
|
||||||
|
'event': logentry.event.slug,
|
||||||
|
'item': logentry.object_id,
|
||||||
|
'action': logentry.action_type,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class ParametrizedOrderPositionWebhookEvent(ParametrizedOrderWebhookEvent):
|
class ParametrizedOrderPositionWebhookEvent(ParametrizedOrderWebhookEvent):
|
||||||
|
|
||||||
def build_payload(self, logentry: LogEntry):
|
def build_payload(self, logentry: LogEntry):
|
||||||
@@ -305,6 +296,11 @@ def register_default_webhook_events(sender, **kwargs):
|
|||||||
'pretix.subevent.deleted',
|
'pretix.subevent.deleted',
|
||||||
pgettext_lazy('subevent', 'Event series date deleted'),
|
pgettext_lazy('subevent', 'Event series date deleted'),
|
||||||
),
|
),
|
||||||
|
ParametrizedItemWebhookEvent(
|
||||||
|
'pretix.event.item.*',
|
||||||
|
_('Product changed (including product added or deleted and including changes to nested objects like '
|
||||||
|
'variations or bundles)'),
|
||||||
|
),
|
||||||
ParametrizedEventWebhookEvent(
|
ParametrizedEventWebhookEvent(
|
||||||
'pretix.event.live.activated',
|
'pretix.event.live.activated',
|
||||||
_('Shop taken live'),
|
_('Shop taken live'),
|
||||||
|
|||||||
@@ -90,7 +90,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</details>
|
</details>
|
||||||
{% empty %}
|
{% empty %}
|
||||||
<div class="alert-info">{% trans "This webhook did not receive any events in the last 30 days." %}</div>
|
<div class="alert alert-info">{% trans "This webhook did not receive any events in the last 30 days." %}</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% include "pretixcontrol/pagination.html" %}
|
{% include "pretixcontrol/pagination.html" %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
Reference in New Issue
Block a user