From 391c42300e7bf367d373dbf65e31dedea5209900 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Fri, 1 Nov 2019 12:22:39 -0400 Subject: [PATCH] Closes #3659: Add filtering for objects in admin UI --- docs/release-notes/version-2.6.md | 1 + netbox/extras/admin.py | 31 +++++++++++++++++++++++++++---- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/docs/release-notes/version-2.6.md b/docs/release-notes/version-2.6.md index c118ec224..f53a87642 100644 --- a/docs/release-notes/version-2.6.md +++ b/docs/release-notes/version-2.6.md @@ -6,6 +6,7 @@ * [#3499](https://github.com/netbox-community/netbox/issues/3499) - Add `ca_file_path` to Webhook model to support user supplied CA certificate verification of webhook requests * [#3594](https://github.com/netbox-community/netbox/issues/3594) - Add ChoiceVar for custom scripts * [#3619](https://github.com/netbox-community/netbox/issues/3619) - Add 400GE OSFP interface type +* [#3659](https://github.com/netbox-community/netbox/issues/3659) - Add filtering for objects in admin UI ## Bug Fixes diff --git a/netbox/extras/admin.py b/netbox/extras/admin.py index 1c35be600..f99848b1b 100644 --- a/netbox/extras/admin.py +++ b/netbox/extras/admin.py @@ -40,6 +40,9 @@ class WebhookAdmin(admin.ModelAdmin): 'name', 'models', 'payload_url', 'http_content_type', 'enabled', 'type_create', 'type_update', 'type_delete', 'ssl_verification', ] + list_filter = [ + 'enabled', 'type_create', 'type_update', 'type_delete', 'obj_type', + ] form = WebhookForm def models(self, obj): @@ -70,7 +73,12 @@ class CustomFieldChoiceAdmin(admin.TabularInline): @admin.register(CustomField, site=admin_site) class CustomFieldAdmin(admin.ModelAdmin): inlines = [CustomFieldChoiceAdmin] - list_display = ['name', 'models', 'type', 'required', 'filter_logic', 'default', 'weight', 'description'] + list_display = [ + 'name', 'models', 'type', 'required', 'filter_logic', 'default', 'weight', 'description', + ] + list_filter = [ + 'type', 'required', 'obj_type', + ] form = CustomFieldForm def models(self, obj): @@ -106,7 +114,12 @@ class CustomLinkForm(forms.ModelForm): @admin.register(CustomLink, site=admin_site) class CustomLinkAdmin(admin.ModelAdmin): - list_display = ['name', 'content_type', 'group_name', 'weight'] + list_display = [ + 'name', 'content_type', 'group_name', 'weight', + ] + list_filter = [ + 'content_type', + ] form = CustomLinkForm @@ -116,7 +129,12 @@ class CustomLinkAdmin(admin.ModelAdmin): @admin.register(Graph, site=admin_site) class GraphAdmin(admin.ModelAdmin): - list_display = ['name', 'type', 'weight', 'source'] + list_display = [ + 'name', 'type', 'weight', 'source', + ] + list_filter = [ + 'type', + ] # @@ -139,7 +157,12 @@ class ExportTemplateForm(forms.ModelForm): @admin.register(ExportTemplate, site=admin_site) class ExportTemplateAdmin(admin.ModelAdmin): - list_display = ['name', 'content_type', 'description', 'mime_type', 'file_extension'] + list_display = [ + 'name', 'content_type', 'description', 'mime_type', 'file_extension', + ] + list_filter = [ + 'content_type', + ] form = ExportTemplateForm