mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-13 16:47:34 -06:00
Closes #3259: Add rack and site filters for cables
This commit is contained in:
parent
d2ab41abfb
commit
4889c8ff9b
40
CHANGELOG.md
40
CHANGELOG.md
@ -1,24 +1,34 @@
|
||||
v2.6.6 (FUTURE)
|
||||
|
||||
## Enhancements
|
||||
|
||||
* [#3259](https://github.com/netbox-community/netbox/issues/3259) - Add `rack` and `site` filters for cables
|
||||
|
||||
---
|
||||
|
||||
v2.6.5 (2019-09-25)
|
||||
|
||||
## Enhancements
|
||||
|
||||
* [#3297](https://github.com/netbox-community/netbox/issues/3297) - Include reserved units when calculating rack utilization
|
||||
* [#3347](https://github.com/netbox-community/netbox/issues/3347) - Extend upgrade script to automatically remove stale content types
|
||||
* [#3352](https://github.com/netbox-community/netbox/issues/3352) - Enable filtering changelog API by `changed_object_id`
|
||||
* [#3515](https://github.com/netbox-community/netbox/issues/3515) - Enable export templates for inventory items
|
||||
* [#3524](https://github.com/netbox-community/netbox/issues/3524) - Enable bulk editing of power outlet/power port associations
|
||||
* [#3529](https://github.com/netbox-community/netbox/issues/3529) - Enable filtering circuits list by region
|
||||
* [#3297](https://github.com/netbox-community/netbox/issues/3297) - Include reserved units when calculating rack utilization
|
||||
* [#3347](https://github.com/netbox-community/netbox/issues/3347) - Extend upgrade script to automatically remove stale content types
|
||||
* [#3352](https://github.com/netbox-community/netbox/issues/3352) - Enable filtering changelog API by `changed_object_id`
|
||||
* [#3515](https://github.com/netbox-community/netbox/issues/3515) - Enable export templates for inventory items
|
||||
* [#3524](https://github.com/netbox-community/netbox/issues/3524) - Enable bulk editing of power outlet/power port associations
|
||||
* [#3529](https://github.com/netbox-community/netbox/issues/3529) - Enable filtering circuits list by region
|
||||
|
||||
## Bug Fixes
|
||||
|
||||
* [#3435](https://github.com/netbox-community/netbox/issues/3435) - Change IP/prefix CSV export to reference VRF name instead of RD
|
||||
* [#3464](https://github.com/netbox-community/netbox/issues/3464) - Fix foreground text color on color picker fields
|
||||
* [#3519](https://github.com/netbox-community/netbox/issues/3519) - Prevent cables from being terminated to virtual/wireless interfaces via API
|
||||
* [#3521](https://github.com/netbox-community/netbox/issues/3521) - Fix error in `parseURL` related to variables in API URL
|
||||
* [#3531](https://github.com/netbox-community/netbox/issues/3531) - Fixed rack role foreground color
|
||||
* [#3534](https://github.com/netbox-community/netbox/issues/3534) - Added blank option for untagged VLANs
|
||||
* [#3540](https://github.com/netbox-community/netbox/issues/3540) - Fixed virtual machine interface edit with new inline vlan edit fields
|
||||
* [#3543](https://github.com/netbox-community/netbox/issues/3543) - Added inline VLAN editing to virtual machine interfaces
|
||||
* [#3435](https://github.com/netbox-community/netbox/issues/3435) - Change IP/prefix CSV export to reference VRF name instead of RD
|
||||
* [#3464](https://github.com/netbox-community/netbox/issues/3464) - Fix foreground text color on color picker fields
|
||||
* [#3519](https://github.com/netbox-community/netbox/issues/3519) - Prevent cables from being terminated to virtual/wireless interfaces via API
|
||||
* [#3521](https://github.com/netbox-community/netbox/issues/3521) - Fix error in `parseURL` related to variables in API URL
|
||||
* [#3531](https://github.com/netbox-community/netbox/issues/3531) - Fixed rack role foreground color
|
||||
* [#3534](https://github.com/netbox-community/netbox/issues/3534) - Added blank option for untagged VLANs
|
||||
* [#3540](https://github.com/netbox-community/netbox/issues/3540) - Fixed virtual machine interface edit with new inline vlan edit fields
|
||||
* [#3543](https://github.com/netbox-community/netbox/issues/3543) - Added inline VLAN editing to virtual machine interfaces
|
||||
|
||||
---
|
||||
|
||||
v2.6.4 (2019-09-19)
|
||||
|
||||
@ -39,6 +49,8 @@ v2.6.4 (2019-09-19)
|
||||
* [#3513](https://github.com/netbox-community/netbox/issues/3513) - Fix assignment of tags when creating front/rear ports
|
||||
* [#3514](https://github.com/netbox-community/netbox/issues/3514) - Label TextVar fields when rendering custom script forms
|
||||
|
||||
---
|
||||
|
||||
v2.6.3 (2019-09-04)
|
||||
|
||||
## New Features
|
||||
|
@ -1,6 +1,5 @@
|
||||
import django_filters
|
||||
from django.contrib.auth.models import User
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
from django.db.models import Q
|
||||
|
||||
from extras.filters import CustomFieldFilterSet, LocalConfigContextFilter
|
||||
@ -931,13 +930,28 @@ class CableFilter(django_filters.FilterSet):
|
||||
color = django_filters.MultipleChoiceFilter(
|
||||
choices=COLOR_CHOICES
|
||||
)
|
||||
device = django_filters.CharFilter(
|
||||
method='filter_connected_device',
|
||||
field_name='name'
|
||||
device_id = MultiValueNumberFilter(
|
||||
method='filter_device'
|
||||
)
|
||||
device_id = django_filters.CharFilter(
|
||||
method='filter_connected_device',
|
||||
field_name='pk'
|
||||
device = MultiValueNumberFilter(
|
||||
method='filter_device',
|
||||
field_name='device__name'
|
||||
)
|
||||
rack_id = MultiValueNumberFilter(
|
||||
method='filter_device',
|
||||
field_name='device__rack_id'
|
||||
)
|
||||
rack = MultiValueNumberFilter(
|
||||
method='filter_device',
|
||||
field_name='device__rack__name'
|
||||
)
|
||||
site_id = MultiValueNumberFilter(
|
||||
method='filter_device',
|
||||
field_name='device__site_id'
|
||||
)
|
||||
site = MultiValueNumberFilter(
|
||||
method='filter_device',
|
||||
field_name='device__site__name'
|
||||
)
|
||||
|
||||
class Meta:
|
||||
@ -949,15 +963,12 @@ class CableFilter(django_filters.FilterSet):
|
||||
return queryset
|
||||
return queryset.filter(label__icontains=value)
|
||||
|
||||
def filter_connected_device(self, queryset, name, value):
|
||||
if not value.strip():
|
||||
return queryset
|
||||
try:
|
||||
device = Device.objects.get(**{name: value})
|
||||
except ObjectDoesNotExist:
|
||||
return queryset.none()
|
||||
cable_pks = device.get_cables(pk_list=True)
|
||||
return queryset.filter(pk__in=cable_pks)
|
||||
def filter_device(self, queryset, name, value):
|
||||
queryset = queryset.filter(
|
||||
Q(**{'_termination_a_{}__in'.format(name): value}) |
|
||||
Q(**{'_termination_b_{}__in'.format(name): value})
|
||||
)
|
||||
return queryset
|
||||
|
||||
|
||||
class ConsoleConnectionFilter(django_filters.FilterSet):
|
||||
|
Loading…
Reference in New Issue
Block a user