Browse Source

Fixes #275: Exclude self when checking for overlapping aggregates

Jeremy Stretch 8 years ago
parent
commit
e19ce043d6
1 changed files with 2 additions and 0 deletions
  1. 2 0
      netbox/ipam/models.py

+ 2 - 0
netbox/ipam/models.py

@@ -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]))