Parcourir la source

Fixes #275: Exclude self when checking for overlapping aggregates

Jeremy Stretch il y a 8 ans
Parent
commit
e19ce043d6
1 fichiers modifiés avec 2 ajouts et 0 suppressions
  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
             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]))