From 2c730b08e4ced13f9cda377139b709975bf88e92 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Thu, 25 Apr 2019 15:06:48 -0400 Subject: [PATCH] Fix PowerPort connected_endpoint filtering, ordering --- netbox/dcim/api/serializers.py | 4 ++-- netbox/dcim/filters.py | 4 ++-- netbox/dcim/tables.py | 5 +++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/netbox/dcim/api/serializers.py b/netbox/dcim/api/serializers.py index c81095d29..c2fef96b3 100644 --- a/netbox/dcim/api/serializers.py +++ b/netbox/dcim/api/serializers.py @@ -429,8 +429,8 @@ class PowerPortSerializer(TaggitSerializer, ConnectedEndpointSerializer): class Meta: model = PowerPort fields = [ - 'id', 'device', 'name', 'maximum_draw', 'allocated_draw', 'description', 'connected_endpoint_type', 'connected_endpoint', 'connection_status', - 'cable', 'tags', + 'id', 'device', 'name', 'maximum_draw', 'allocated_draw', 'description', 'connected_endpoint_type', + 'connected_endpoint', 'connection_status', 'cable', 'tags', ] diff --git a/netbox/dcim/filters.py b/netbox/dcim/filters.py index eb7636c94..63a2d3d1a 100644 --- a/netbox/dcim/filters.py +++ b/netbox/dcim/filters.py @@ -1025,14 +1025,14 @@ class PowerConnectionFilter(django_filters.FilterSet): def filter_site(self, queryset, name, value): if not value.strip(): return queryset - return queryset.filter(connected_endpoint__device__site__slug=value) + return queryset.filter(_connected_poweroutlet__device__site__slug=value) def filter_device(self, queryset, name, value): if not value.strip(): return queryset return queryset.filter( Q(device__name__icontains=value) | - Q(connected_endpoint__device__name__icontains=value) + Q(_connected_poweroutlet__device__name__icontains=value) ) diff --git a/netbox/dcim/tables.py b/netbox/dcim/tables.py index 49cd22e10..942e10029 100644 --- a/netbox/dcim/tables.py +++ b/netbox/dcim/tables.py @@ -707,7 +707,8 @@ class PowerConnectionTable(BaseTable): args=[Accessor('connected_endpoint.device.pk')], verbose_name='PDU' ) - connected_endpoint = tables.Column( + outlet = tables.Column( + accessor=Accessor('_connected_poweroutlet'), verbose_name='Outlet' ) device = tables.LinkColumn( @@ -720,7 +721,7 @@ class PowerConnectionTable(BaseTable): class Meta(BaseTable.Meta): model = PowerPort - fields = ('pdu', 'connected_endpoint', 'device', 'name', 'connection_status') + fields = ('pdu', 'outlet', 'device', 'name', 'connection_status') class InterfaceConnectionTable(BaseTable):