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:
@ -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 the Cluster is assigned to a Site, verify that all host Devices belong to that Site.
|
||||||
if self.pk and self.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:
|
if nonsite_devices:
|
||||||
raise ValidationError({
|
raise ValidationError({
|
||||||
'site': "{} devices are assigned as hosts for this cluster but are not in site {}".format(
|
'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
|
# 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
|
# 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.
|
# 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
|
name=self.name, tenant__isnull=True
|
||||||
):
|
):
|
||||||
raise ValidationError({
|
raise ValidationError({
|
||||||
|
Reference in New Issue
Block a user