mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Fixes #275: Exclude self when checking for overlapping aggregates
This commit is contained in:
@ -123,6 +123,8 @@ class Aggregate(CreatedUpdatedModel):
|
|||||||
|
|
||||||
# Ensure that the aggregate being added does not cover an existing aggregate
|
# Ensure that the aggregate being added does not cover an existing aggregate
|
||||||
covered_aggregates = Aggregate.objects.filter(prefix__net_contained=str(self.prefix))
|
covered_aggregates = Aggregate.objects.filter(prefix__net_contained=str(self.prefix))
|
||||||
|
if self.pk:
|
||||||
|
covered_aggregates = covered_aggregates.exclude(pk=self.pk)
|
||||||
if covered_aggregates:
|
if covered_aggregates:
|
||||||
raise ValidationError("{} is overlaps with an existing aggregate ({})"
|
raise ValidationError("{} is overlaps with an existing aggregate ({})"
|
||||||
.format(self.prefix, covered_aggregates[0]))
|
.format(self.prefix, covered_aggregates[0]))
|
||||||
|
Reference in New Issue
Block a user