1
0
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:
Jeremy Stretch
2016-07-13 10:37:25 -04:00
parent 03542b400d
commit e19ce043d6

View File

@ -123,6 +123,8 @@ class Aggregate(CreatedUpdatedModel):
# Ensure that the aggregate being added does not cover an existing aggregate
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:
raise ValidationError("{} is overlaps with an existing aggregate ({})"
.format(self.prefix, covered_aggregates[0]))