1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Fix evaluation of RestrictedQuerySets

This commit is contained in:
Jeremy Stretch
2020-06-29 11:48:36 -04:00
parent eb45ad600e
commit 6ecbf45974

View File

@ -176,7 +176,7 @@ class Cluster(ChangeLoggedModel, CustomFieldModel):
# If the Cluster is assigned to a Site, verify that all host Devices belong to that Site.
if self.pk and self.site:
nonsite_devices = Device.objects.filter(cluster=self).exclude(site=self.site).count()
nonsite_devices = Device.objects.unrestricted().filter(cluster=self).exclude(site=self.site).count()
if nonsite_devices:
raise ValidationError({
'site': "{} devices are assigned as hosts for this cluster but are not in site {}".format(
@ -316,7 +316,7 @@ class VirtualMachine(ChangeLoggedModel, ConfigContextModel, CustomFieldModel):
# Check for a duplicate name on a VM assigned to the same Cluster and no Tenant. This is necessary
# because Django does not consider two NULL fields to be equal, and thus will not trigger a violation
# of the uniqueness constraint without manual intervention.
if self.tenant is None and VirtualMachine.objects.exclude(pk=self.pk).filter(
if self.tenant is None and VirtualMachine.objects.unrestricted().exclude(pk=self.pk).filter(
name=self.name, tenant__isnull=True
):
raise ValidationError({