From fd4a9db13e27034d23ac07f014ec3f388ae258e4 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Tue, 6 Nov 2018 09:24:05 -0500 Subject: [PATCH] Closes #2512: Add device field to inventory item filter form --- CHANGELOG.md | 6 +++++- netbox/dcim/filters.py | 9 +++++++++ netbox/dcim/forms.py | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f258406f6..877a45a1e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,12 @@ v2.4.7 (FUTURE) +## Enhancements + +* [#2427](https://github.com/digitalocean/netbox/issues/2427) - Allow filtering of interfaces by assigned VLAN or VLAN ID +* [#2512](https://github.com/digitalocean/netbox/issues/2512) - Add device field to inventory item filter form + ## Bug Fixes -* [#2427](https://github.com/digitalocean/netbox/issues/2427) - Allow filtering of interfaces by assigned VLAN or VLAN ID * [#2502](https://github.com/digitalocean/netbox/issues/2502) - Allow duplicate VIPs inside a uniqueness-enforced VRF * [#2514](https://github.com/digitalocean/netbox/issues/2514) - Prevent new connections to already connected interfaces * [#2515](https://github.com/digitalocean/netbox/issues/2515) - Only use django-rq admin tmeplate if webhooks are enabled diff --git a/netbox/dcim/filters.py b/netbox/dcim/filters.py index 424e99b59..1870df762 100644 --- a/netbox/dcim/filters.py +++ b/netbox/dcim/filters.py @@ -707,6 +707,15 @@ class InventoryItemFilter(DeviceComponentFilterSet): method='search', label='Search', ) + device_id = django_filters.ModelChoiceFilter( + queryset=Device.objects.all(), + label='Device (ID)', + ) + device = django_filters.ModelChoiceFilter( + queryset=Device.objects.all(), + to_field_name='name', + label='Device (name)', + ) parent_id = django_filters.ModelMultipleChoiceFilter( queryset=InventoryItem.objects.all(), label='Parent inventory item (ID)', diff --git a/netbox/dcim/forms.py b/netbox/dcim/forms.py index 6b6ea1187..b24c979c5 100644 --- a/netbox/dcim/forms.py +++ b/netbox/dcim/forms.py @@ -2201,6 +2201,7 @@ class InventoryItemBulkEditForm(BootstrapMixin, BulkEditForm): class InventoryItemFilterForm(BootstrapMixin, forms.Form): model = InventoryItem q = forms.CharField(required=False, label='Search') + device = forms.CharField(required=False, label='Device name') manufacturer = FilterChoiceField( queryset=Manufacturer.objects.annotate(filter_count=Count('inventory_items')), to_field_name='slug',