Просмотр исходного кода

Closes #2512: Add device field to inventory item filter form

Jeremy Stretch 7 лет назад
Родитель
Сommit
fd4a9db13e
3 измененных файлов с 15 добавлено и 1 удалено
  1. 5 1
      CHANGELOG.md
  2. 9 0
      netbox/dcim/filters.py
  3. 1 0
      netbox/dcim/forms.py

+ 5 - 1
CHANGELOG.md

@@ -1,8 +1,12 @@
 v2.4.7 (FUTURE)
 
-## Bug Fixes
+## 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
+
 * [#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

+ 9 - 0
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)',

+ 1 - 0
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',