mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Fixes #3507: Filtering IP by multiple devices
This commit is contained in:
@ -26,6 +26,7 @@
|
|||||||
|
|
||||||
## Bug Fixes
|
## Bug Fixes
|
||||||
|
|
||||||
|
* [#3507](https://github.com/netbox-community/netbox/issues/3507) - Fix filtering IPaddress by multiple devices
|
||||||
* [#4030](https://github.com/netbox-community/netbox/issues/4030) - Fix exception when bulk editing interfaces (revised)
|
* [#4030](https://github.com/netbox-community/netbox/issues/4030) - Fix exception when bulk editing interfaces (revised)
|
||||||
* [#4043](https://github.com/netbox-community/netbox/issues/4043) - Fix toggling of required fields in custom scripts
|
* [#4043](https://github.com/netbox-community/netbox/issues/4043) - Fix toggling of required fields in custom scripts
|
||||||
* [#4049](https://github.com/netbox-community/netbox/issues/4049) - Restore missing `tags` field in IPAM service serializer
|
* [#4049](https://github.com/netbox-community/netbox/issues/4049) - Restore missing `tags` field in IPAM service serializer
|
||||||
|
@ -304,14 +304,15 @@ class IPAddressFilterSet(TenancyFilterSet, CustomFieldFilterSet, CreatedUpdatedF
|
|||||||
to_field_name='rd',
|
to_field_name='rd',
|
||||||
label='VRF (RD)',
|
label='VRF (RD)',
|
||||||
)
|
)
|
||||||
device = django_filters.CharFilter(
|
device = django_filters.ModelMultipleChoiceFilter(
|
||||||
method='filter_device',
|
field_name='interface__device__name',
|
||||||
field_name='name',
|
queryset=Device.objects.all(),
|
||||||
label='Device',
|
to_field_name='name',
|
||||||
|
label='Device (name)',
|
||||||
)
|
)
|
||||||
device_id = django_filters.NumberFilter(
|
device_id = django_filters.ModelMultipleChoiceFilter(
|
||||||
method='filter_device',
|
field_name='interface__device',
|
||||||
field_name='pk',
|
queryset=Device.objects.all(),
|
||||||
label='Device (ID)',
|
label='Device (ID)',
|
||||||
)
|
)
|
||||||
virtual_machine_id = django_filters.ModelMultipleChoiceFilter(
|
virtual_machine_id = django_filters.ModelMultipleChoiceFilter(
|
||||||
|
@ -392,13 +392,12 @@ class IPAddressTestCase(TestCase):
|
|||||||
params = {'vrf': [vrfs[0].rd, vrfs[1].rd]}
|
params = {'vrf': [vrfs[0].rd, vrfs[1].rd]}
|
||||||
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 4)
|
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 4)
|
||||||
|
|
||||||
# TODO: Test for multiple values
|
|
||||||
def test_device(self):
|
def test_device(self):
|
||||||
device = Device.objects.first()
|
devices = Device.objects.all()[:2]
|
||||||
params = {'device_id': device.pk}
|
params = {'device_id': [devices[0].pk, devices[1].pk]}
|
||||||
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1)
|
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
|
||||||
params = {'device': device.name}
|
params = {'device': [devices[0].name, devices[1].name]}
|
||||||
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1)
|
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
|
||||||
|
|
||||||
def test_virtual_machine(self):
|
def test_virtual_machine(self):
|
||||||
vms = VirtualMachine.objects.all()[:2]
|
vms = VirtualMachine.objects.all()[:2]
|
||||||
|
Reference in New Issue
Block a user