fix bug preventing deployment admin from updating deployment flavors on ssave. fix nameError bug
diff --git a/planetstack/core/admin.py b/planetstack/core/admin.py
index bc84554..7fa537a 100644
--- a/planetstack/core/admin.py
+++ b/planetstack/core/admin.py
@@ -604,7 +604,15 @@
# a better way...
self.manipulate_m2m_objs(deployment, self.cleaned_data['sites'], deployment.sitedeployments.all(), SiteDeployments, "deployment", "site")
- self.manipulate_m2m_objs(deployment, self.cleaned_data['images'], deployment.imagedeployments.all(), DeploymentImages, "deployment", "image")
+ self.manipulate_m2m_objs(deployment, self.cleaned_data['images'], deployment.imagedeployments.all(), ImageDeployments, "deployment", "image")
+ # manipulate_m2m_objs doesn't work for Flavor/Deployment relationship
+ # so well handle that manually here
+ for flavor in deployment.flavors.all():
+ if getattr(flavor, 'name') not in self.cleaned_data['flavors']:
+ flavor.delete()
+ for flavor in self.cleaned_data['flavors']:
+ if flavor not in deployment.flavors.all():
+ flavor.deployments.add(deployment)
self.save_m2m()