mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
@ -107,9 +107,9 @@ class WebhookSerializer(NetBoxModelSerializer):
|
|||||||
class Meta:
|
class Meta:
|
||||||
model = Webhook
|
model = Webhook
|
||||||
fields = [
|
fields = [
|
||||||
'id', 'url', 'display', 'name', 'payload_url', 'http_method', 'http_content_type', 'additional_headers',
|
'id', 'url', 'display', 'name', 'description', 'payload_url', 'http_method', 'http_content_type',
|
||||||
'body_template', 'secret', 'ssl_verification', 'ca_file_path', 'custom_fields', 'tags', 'created',
|
'additional_headers', 'body_template', 'secret', 'ssl_verification', 'ca_file_path', 'custom_fields',
|
||||||
'last_updated',
|
'tags', 'created', 'last_updated',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -58,6 +58,7 @@ class WebhookFilterSet(NetBoxModelFilterSet):
|
|||||||
return queryset
|
return queryset
|
||||||
return queryset.filter(
|
return queryset.filter(
|
||||||
Q(name__icontains=value) |
|
Q(name__icontains=value) |
|
||||||
|
Q(description__icontains=value) |
|
||||||
Q(payload_url__icontains=value)
|
Q(payload_url__icontains=value)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -178,6 +178,11 @@ class WebhookBulkEditForm(NetBoxModelBulkEditForm):
|
|||||||
queryset=Webhook.objects.all(),
|
queryset=Webhook.objects.all(),
|
||||||
widget=forms.MultipleHiddenInput
|
widget=forms.MultipleHiddenInput
|
||||||
)
|
)
|
||||||
|
description = forms.CharField(
|
||||||
|
label=_('Description'),
|
||||||
|
max_length=200,
|
||||||
|
required=False
|
||||||
|
)
|
||||||
http_method = forms.ChoiceField(
|
http_method = forms.ChoiceField(
|
||||||
choices=add_blank_choice(WebhookHttpMethodChoices),
|
choices=add_blank_choice(WebhookHttpMethodChoices),
|
||||||
required=False,
|
required=False,
|
||||||
@ -242,7 +247,7 @@ class EventRuleBulkEditForm(NetBoxModelBulkEditForm):
|
|||||||
widget=BulkEditNullBooleanSelect()
|
widget=BulkEditNullBooleanSelect()
|
||||||
)
|
)
|
||||||
|
|
||||||
nullable_fields = ('conditions',)
|
nullable_fields = ('description', 'conditions',)
|
||||||
|
|
||||||
|
|
||||||
class TagBulkEditForm(BulkEditForm):
|
class TagBulkEditForm(BulkEditForm):
|
||||||
|
@ -150,7 +150,7 @@ class WebhookImportForm(NetBoxModelImportForm):
|
|||||||
model = Webhook
|
model = Webhook
|
||||||
fields = (
|
fields = (
|
||||||
'name', 'payload_url', 'http_method', 'http_content_type', 'additional_headers', 'body_template',
|
'name', 'payload_url', 'http_method', 'http_content_type', 'additional_headers', 'body_template',
|
||||||
'secret', 'ssl_verification', 'ca_file_path', 'tags'
|
'secret', 'ssl_verification', 'ca_file_path', 'description', 'tags'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -215,7 +215,7 @@ class BookmarkForm(BootstrapMixin, forms.ModelForm):
|
|||||||
class WebhookForm(NetBoxModelForm):
|
class WebhookForm(NetBoxModelForm):
|
||||||
|
|
||||||
fieldsets = (
|
fieldsets = (
|
||||||
(_('Webhook'), ('name', 'tags',)),
|
(_('Webhook'), ('name', 'description', 'tags',)),
|
||||||
(_('HTTP Request'), (
|
(_('HTTP Request'), (
|
||||||
'payload_url', 'http_method', 'http_content_type', 'additional_headers', 'body_template', 'secret',
|
'payload_url', 'http_method', 'http_content_type', 'additional_headers', 'body_template', 'secret',
|
||||||
)),
|
)),
|
||||||
|
@ -124,4 +124,9 @@ class Migration(migrations.Migration):
|
|||||||
name='tags',
|
name='tags',
|
||||||
field=taggit.managers.TaggableManager(through='extras.TaggedItem', to='extras.Tag'),
|
field=taggit.managers.TaggableManager(through='extras.TaggedItem', to='extras.Tag'),
|
||||||
),
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='webhook',
|
||||||
|
name='description',
|
||||||
|
field=models.CharField(blank=True, max_length=200),
|
||||||
|
),
|
||||||
]
|
]
|
||||||
|
@ -182,6 +182,11 @@ class Webhook(CustomFieldsMixin, ExportTemplatesMixin, TagsMixin, ChangeLoggedMo
|
|||||||
max_length=150,
|
max_length=150,
|
||||||
unique=True
|
unique=True
|
||||||
)
|
)
|
||||||
|
description = models.CharField(
|
||||||
|
verbose_name=_('description'),
|
||||||
|
max_length=200,
|
||||||
|
blank=True
|
||||||
|
)
|
||||||
payload_url = models.CharField(
|
payload_url = models.CharField(
|
||||||
max_length=500,
|
max_length=500,
|
||||||
verbose_name=_('URL'),
|
verbose_name=_('URL'),
|
||||||
|
@ -9,3 +9,12 @@ class JournalEntryIndex(SearchIndex):
|
|||||||
('comments', 5000),
|
('comments', 5000),
|
||||||
)
|
)
|
||||||
category = 'Journal'
|
category = 'Journal'
|
||||||
|
|
||||||
|
|
||||||
|
@register_search
|
||||||
|
class WebhookEntryIndex(SearchIndex):
|
||||||
|
model = models.Webhook
|
||||||
|
fields = (
|
||||||
|
('name', 100),
|
||||||
|
('description', 500),
|
||||||
|
)
|
||||||
|
@ -262,10 +262,10 @@ class WebhookTable(NetBoxTable):
|
|||||||
model = Webhook
|
model = Webhook
|
||||||
fields = (
|
fields = (
|
||||||
'pk', 'id', 'name', 'http_method', 'payload_url', 'http_content_type', 'secret', 'ssl_verification',
|
'pk', 'id', 'name', 'http_method', 'payload_url', 'http_content_type', 'secret', 'ssl_verification',
|
||||||
'ca_file_path', 'tags', 'created', 'last_updated',
|
'ca_file_path', 'description', 'tags', 'created', 'last_updated',
|
||||||
)
|
)
|
||||||
default_columns = (
|
default_columns = (
|
||||||
'pk', 'name', 'http_method', 'payload_url',
|
'pk', 'name', 'http_method', 'payload_url', 'description',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -46,6 +46,7 @@ class WebhookTest(APIViewTestCases.APIViewTestCase):
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
bulk_update_data = {
|
bulk_update_data = {
|
||||||
|
'description': 'New description',
|
||||||
'ssl_verification': False,
|
'ssl_verification': False,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -347,20 +347,21 @@ class WebhookTestCase(ViewTestCases.PrimaryObjectViewTestCase):
|
|||||||
'payload_url': 'http://example.com/?x',
|
'payload_url': 'http://example.com/?x',
|
||||||
'http_method': 'GET',
|
'http_method': 'GET',
|
||||||
'http_content_type': 'application/foo',
|
'http_content_type': 'application/foo',
|
||||||
|
'description': 'My webhook',
|
||||||
}
|
}
|
||||||
|
|
||||||
cls.csv_data = (
|
cls.csv_data = (
|
||||||
"name,payload_url,http_method,http_content_type",
|
"name,payload_url,http_method,http_content_type,description",
|
||||||
"Webhook 4,http://example.com/?4,GET,application/json",
|
"Webhook 4,http://example.com/?4,GET,application/json,Foo",
|
||||||
"Webhook 5,http://example.com/?5,GET,application/json",
|
"Webhook 5,http://example.com/?5,GET,application/json,Bar",
|
||||||
"Webhook 6,http://example.com/?6,GET,application/json",
|
"Webhook 6,http://example.com/?6,GET,application/json,Baz",
|
||||||
)
|
)
|
||||||
|
|
||||||
cls.csv_update_data = (
|
cls.csv_update_data = (
|
||||||
"id,name",
|
"id,name,description",
|
||||||
f"{webhooks[0].pk},Webhook 7",
|
f"{webhooks[0].pk},Webhook 7,Foo",
|
||||||
f"{webhooks[1].pk},Webhook 8",
|
f"{webhooks[1].pk},Webhook 8,Bar",
|
||||||
f"{webhooks[2].pk},Webhook 9",
|
f"{webhooks[2].pk},Webhook 9,Baz",
|
||||||
)
|
)
|
||||||
|
|
||||||
cls.bulk_edit_data = {
|
cls.bulk_edit_data = {
|
||||||
@ -403,7 +404,8 @@ class EventRulesTestCase(ViewTestCases.PrimaryObjectViewTestCase):
|
|||||||
'action_type': 'webhook',
|
'action_type': 'webhook',
|
||||||
'action_object_type': webhook_ct.pk,
|
'action_object_type': webhook_ct.pk,
|
||||||
'action_object_id': webhooks[0].pk,
|
'action_object_id': webhooks[0].pk,
|
||||||
'action_choice': webhooks[0]
|
'action_choice': webhooks[0],
|
||||||
|
'description': 'New description',
|
||||||
}
|
}
|
||||||
|
|
||||||
cls.csv_data = (
|
cls.csv_data = (
|
||||||
|
@ -16,6 +16,10 @@
|
|||||||
<th scope="row">{% trans "Name" %}</th>
|
<th scope="row">{% trans "Name" %}</th>
|
||||||
<td>{{ object.name }}</td>
|
<td>{{ object.name }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th scope="row">{% trans "Description" %}</th>
|
||||||
|
<td>{{ object.description|placeholder }}</td>
|
||||||
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Reference in New Issue
Block a user