Webhooks: Add comment field (#3095)

This commit is contained in:
ser8phin
2023-02-07 15:17:19 +01:00
committed by GitHub
parent ba2c6e1e58
commit 82dd417a8e
7 changed files with 29 additions and 2 deletions

View File

@@ -0,0 +1,18 @@
# Generated by Django 3.2.17 on 2023-02-07 12:18
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('pretixapi', '0009_auto_20221217_1847'),
]
operations = [
migrations.AddField(
model_name='webhook',
name='comment',
field=models.CharField(max_length=255, null=True),
),
]

View File

@@ -112,6 +112,7 @@ class WebHook(models.Model):
target_url = models.URLField(verbose_name=_("Target URL"), max_length=255)
all_events = models.BooleanField(default=True, verbose_name=_("All events (including newly created ones)"))
limit_events = models.ManyToManyField('pretixbase.Event', verbose_name=_("Limit to events"), blank=True)
comment = models.CharField(verbose_name=_("Comment"), max_length=255, null=True, blank=True)
class Meta:
ordering = ('id',)

View File

@@ -55,7 +55,7 @@ class WebHookSerializer(I18nAwareModelSerializer):
class Meta:
model = WebHook
fields = ('id', 'enabled', 'target_url', 'all_events', 'limit_events', 'action_types')
fields = ('id', 'enabled', 'target_url', 'all_events', 'limit_events', 'action_types', 'comment')
def validate(self, data):
data = super().validate(data)

View File

@@ -564,7 +564,7 @@ class WebHookForm(forms.ModelForm):
class Meta:
model = WebHook
fields = ['target_url', 'enabled', 'all_events', 'limit_events']
fields = ['target_url', 'enabled', 'all_events', 'limit_events', 'comment']
widgets = {
'limit_events': forms.CheckboxSelectMultiple(attrs={
'data-inverse-dependency': '#id_all_events'

View File

@@ -11,6 +11,7 @@
{% csrf_token %}
{% bootstrap_form_errors form %}
{% bootstrap_field form.target_url layout="control" %}
{% bootstrap_field form.comment layout="control" %}
{% bootstrap_field form.enabled layout="control" %}
{% bootstrap_field form.events layout="control" %}
{% bootstrap_field form.all_events layout="control" %}

View File

@@ -35,6 +35,7 @@
<tr>
<th>{% trans "Target URL" %}</th>
<th>{% trans "Events" %}</th>
<th>{% trans "Comment" %}</th>
<th></th>
</tr>
</thead>
@@ -61,6 +62,11 @@
</ul>
{% endif %}
</td>
<td>
{% if w.comment %}
{{ w.comment }}
{% endif %}
</td>
<td class="text-right flip">
<a href="{% url "control:organizer.webhook.edit" organizer=request.organizer.slug webhook=w.id %}"
class="btn btn-default btn-sm" data-toggle="tooltip" title="{% trans "Edit" %}">

View File

@@ -47,6 +47,7 @@ TEST_WEBHOOK_RES = {
"all_events": False,
"limit_events": ['dummy'],
"action_types": ['pretix.event.order.paid', 'pretix.event.order.placed'],
"comment": None,
}