mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-22 20:12:00 -06:00
Fix unrestricted querysets
This commit is contained in:
parent
327a93136a
commit
847fbfd71a
@ -390,7 +390,7 @@ class IPAddressFilterSet(BaseFilterSet, TenancyFilterSet, CustomFieldFilterSet,
|
||||
return queryset.filter(address__net_mask_length=value)
|
||||
|
||||
def filter_device(self, queryset, name, value):
|
||||
devices = Device.objects.filter(**{'{}__in'.format(name): value})
|
||||
devices = Device.objects.unrestricted().filter(**{'{}__in'.format(name): value})
|
||||
if not devices.exists():
|
||||
return queryset.none()
|
||||
interface_ids = []
|
||||
@ -401,12 +401,12 @@ class IPAddressFilterSet(BaseFilterSet, TenancyFilterSet, CustomFieldFilterSet,
|
||||
)
|
||||
|
||||
def filter_virtual_machine(self, queryset, name, value):
|
||||
virtual_machines = VirtualMachine.objects.filter(**{'{}__in'.format(name): value})
|
||||
virtual_machines = VirtualMachine.objects.unrestricted().filter(**{'{}__in'.format(name): value})
|
||||
if not virtual_machines.exists():
|
||||
return queryset.none()
|
||||
interface_ids = []
|
||||
for vm in virtual_machines:
|
||||
interface_ids.extend(vm.interfaces.values_list('id', flat=True))
|
||||
interface_ids.extend(vm.interfaces.unrestricted().values_list('id', flat=True))
|
||||
return queryset.filter(
|
||||
vminterface__in=interface_ids
|
||||
)
|
||||
|
@ -471,7 +471,7 @@ class Prefix(ChangeLoggedModel, CustomFieldModel):
|
||||
return self.STATUS_CLASS_MAP.get(self.status)
|
||||
|
||||
def get_duplicates(self):
|
||||
return Prefix.objects.filter(vrf=self.vrf, prefix=str(self.prefix)).exclude(pk=self.pk)
|
||||
return Prefix.objects.unrestricted().filter(vrf=self.vrf, prefix=str(self.prefix)).exclude(pk=self.pk)
|
||||
|
||||
def get_child_prefixes(self):
|
||||
"""
|
||||
@ -479,9 +479,9 @@ class Prefix(ChangeLoggedModel, CustomFieldModel):
|
||||
Prefixes belonging to any VRF.
|
||||
"""
|
||||
if self.vrf is None and self.status == PrefixStatusChoices.STATUS_CONTAINER:
|
||||
return Prefix.objects.filter(prefix__net_contained=str(self.prefix))
|
||||
return Prefix.objects.unrestricted().filter(prefix__net_contained=str(self.prefix))
|
||||
else:
|
||||
return Prefix.objects.filter(prefix__net_contained=str(self.prefix), vrf=self.vrf)
|
||||
return Prefix.objects.unrestricted().filter(prefix__net_contained=str(self.prefix), vrf=self.vrf)
|
||||
|
||||
def get_child_ips(self):
|
||||
"""
|
||||
@ -489,9 +489,9 @@ class Prefix(ChangeLoggedModel, CustomFieldModel):
|
||||
child IPAddresses belonging to any VRF.
|
||||
"""
|
||||
if self.vrf is None and self.status == PrefixStatusChoices.STATUS_CONTAINER:
|
||||
return IPAddress.objects.filter(address__net_host_contained=str(self.prefix))
|
||||
return IPAddress.objects.unrestricted().filter(address__net_host_contained=str(self.prefix))
|
||||
else:
|
||||
return IPAddress.objects.filter(address__net_host_contained=str(self.prefix), vrf=self.vrf)
|
||||
return IPAddress.objects.unrestricted().filter(address__net_host_contained=str(self.prefix), vrf=self.vrf)
|
||||
|
||||
def get_available_prefixes(self):
|
||||
"""
|
||||
@ -695,7 +695,10 @@ class IPAddress(ChangeLoggedModel, CustomFieldModel):
|
||||
return reverse('ipam:ipaddress', args=[self.pk])
|
||||
|
||||
def get_duplicates(self):
|
||||
return IPAddress.objects.filter(vrf=self.vrf, address__net_host=str(self.address.ip)).exclude(pk=self.pk)
|
||||
return IPAddress.objects.unrestricted().filter(
|
||||
vrf=self.vrf,
|
||||
address__net_host=str(self.address.ip)
|
||||
).exclude(pk=self.pk)
|
||||
|
||||
def clean(self):
|
||||
|
||||
@ -992,7 +995,7 @@ class VLAN(ChangeLoggedModel, CustomFieldModel):
|
||||
|
||||
def get_members(self):
|
||||
# Return all interfaces assigned to this VLAN
|
||||
return Interface.objects.filter(
|
||||
return Interface.objects.unrestricted().filter(
|
||||
Q(untagged_vlan_id=self.pk) |
|
||||
Q(tagged_vlans=self.pk)
|
||||
).distinct()
|
||||
|
Loading…
Reference in New Issue
Block a user