|
@@ -1,6 +1,5 @@
|
|
|
import django_filters
|
|
import django_filters
|
|
|
from django.contrib.auth.models import User
|
|
from django.contrib.auth.models import User
|
|
|
-from django.db.models import Q
|
|
|
|
|
|
|
|
|
|
from extras.filters import CustomFieldFilterSet, LocalConfigContextFilterSet, CreatedUpdatedFilterSet
|
|
from extras.filters import CustomFieldFilterSet, LocalConfigContextFilterSet, CreatedUpdatedFilterSet
|
|
|
from tenancy.filters import TenancyFilterSet
|
|
from tenancy.filters import TenancyFilterSet
|
|
@@ -356,6 +355,10 @@ class DeviceTypeFilterSet(CustomFieldFilterSet, CreatedUpdatedFilterSet):
|
|
|
method='_pass_through_ports',
|
|
method='_pass_through_ports',
|
|
|
label='Has pass-through ports',
|
|
label='Has pass-through ports',
|
|
|
)
|
|
)
|
|
|
|
|
+ device_bays = django_filters.BooleanFilter(
|
|
|
|
|
+ method='_device_bays',
|
|
|
|
|
+ label='Has device bays',
|
|
|
|
|
+ )
|
|
|
tag = TagFilter()
|
|
tag = TagFilter()
|
|
|
|
|
|
|
|
class Meta:
|
|
class Meta:
|
|
@@ -395,6 +398,9 @@ class DeviceTypeFilterSet(CustomFieldFilterSet, CreatedUpdatedFilterSet):
|
|
|
rearport_templates__isnull=value
|
|
rearport_templates__isnull=value
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
|
|
+ def _device_bays(self, queryset, name, value):
|
|
|
|
|
+ return queryset.exclude(device_bay_templates__isnull=value)
|
|
|
|
|
+
|
|
|
|
|
|
|
|
class DeviceTypeComponentFilterSet(NameSlugSearchFilterSet):
|
|
class DeviceTypeComponentFilterSet(NameSlugSearchFilterSet):
|
|
|
devicetype_id = django_filters.ModelMultipleChoiceFilter(
|
|
devicetype_id = django_filters.ModelMultipleChoiceFilter(
|
|
@@ -623,6 +629,10 @@ class DeviceFilterSet(LocalConfigContextFilterSet, TenancyFilterSet, CustomField
|
|
|
method='_pass_through_ports',
|
|
method='_pass_through_ports',
|
|
|
label='Has pass-through ports',
|
|
label='Has pass-through ports',
|
|
|
)
|
|
)
|
|
|
|
|
+ device_bays = django_filters.BooleanFilter(
|
|
|
|
|
+ method='_device_bays',
|
|
|
|
|
+ label='Has device bays',
|
|
|
|
|
+ )
|
|
|
tag = TagFilter()
|
|
tag = TagFilter()
|
|
|
|
|
|
|
|
class Meta:
|
|
class Meta:
|
|
@@ -676,6 +686,9 @@ class DeviceFilterSet(LocalConfigContextFilterSet, TenancyFilterSet, CustomField
|
|
|
rearports__isnull=value
|
|
rearports__isnull=value
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
|
|
+ def _device_bays(self, queryset, name, value):
|
|
|
|
|
+ return queryset.exclude(device_bays__isnull=value)
|
|
|
|
|
+
|
|
|
|
|
|
|
|
class DeviceComponentFilterSet(django_filters.FilterSet):
|
|
class DeviceComponentFilterSet(django_filters.FilterSet):
|
|
|
q = django_filters.CharFilter(
|
|
q = django_filters.CharFilter(
|