mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-16 04:02:52 -06:00
Fixes #275: Exclude self when checking for overlapping aggregates
This commit is contained in:
parent
03542b400d
commit
e19ce043d6
@ -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]))
|
||||||
|
Loading…
Reference in New Issue
Block a user