cleanup network objects associated with slice that's deleted
diff --git a/planetstack/core/models/slice.py b/planetstack/core/models/slice.py
index 7915d42..7412fe2 100644
--- a/planetstack/core/models/slice.py
+++ b/planetstack/core/models/slice.py
@@ -87,6 +87,13 @@
qs = Slice.objects.filter(id__in=slice_ids)
return qs
+ def delete(self, *args, **kwds):
+ # delete networks associated with this slice
+ from core.models.network import Network
+ nets = Network.objects.filter(slices=self)
+ nets.delete()
+ super(SliceAdmin, self).delete(*args, **kwds)
+
class SliceRole(PlCoreBase):
ROLE_CHOICES = (('admin','Admin'),('default','Default'))