Fixes #67: Improved Aggregate validation; extended aggregate documentation

This commit is contained in:
Jeremy Stretch
2016-06-28 10:04:03 -04:00
parent 4dac43c1c9
commit 6848a3dc81
2 changed files with 8 additions and 0 deletions

View File

@@ -121,6 +121,12 @@ class Aggregate(CreatedUpdatedModel):
raise ValidationError("{} is already covered by an existing aggregate ({})"
.format(self.prefix, covering_aggregates[0]))
# Ensure that the aggregate being added does not cover an existing aggregate
covered_aggregates = Aggregate.objects.filter(prefix__net_contained=str(self.prefix))
if covered_aggregates:
raise ValidationError("{} is overlaps with an existing aggregate ({})"
.format(self.prefix, covered_aggregates[0]))
def save(self, *args, **kwargs):
if self.prefix:
# Infer address family from IPNetwork object