Failing hard at care

This commit is contained in:
Joseph Kennedy 2017-08-30 21:02:10 -04:00
parent 4afce0f0d4
commit 560a0e7758

View File

@ -622,17 +622,17 @@ class InterfaceListFilter(django_filters.FilterSet):
def filter_site(self, queryset, name, value): def filter_site(self, queryset, name, value):
try: try:
site = Device.objects.select_related('device_id','site').get(**{name: value}) device = Device.objects.select_related('site').get(**{name: value})
ordering = device.site.interface_ordering ordering = device.device_type.interface_ordering
return queryset.filter(device=device_id).order_naturally(ordering) return queryset.filter(device=device).order_naturally(ordering)
except Device.DoesNotExist: except Device.DoesNotExist:
return queryset.none() return queryset.none()
def filter_role(self, queryset, name, value): def filter_role(self, queryset, name, value):
try: try:
site = Device.objects.select_related('device_id','device_role').get(**{name: value}) device = Device.objects.select_related('device_role').get(**{name: value})
ordering = device.device_role.interface_ordering ordering = device.device_type.interface_ordering
return queryset.filter(device=device_id).order_naturally(ordering) return queryset.filter(device=device).order_naturally(ordering)
except Device.DoesNotExist: except Device.DoesNotExist:
return queryset.none() return queryset.none()