only admins can save/update controllers
Tony Mack [Tue, 13 Jan 2015 22:33:08 +0000 (17:33 -0500)]
planetstack/core/admin.py
planetstack/core/models/site.py

index 29cecfd..8c9e050 100644 (file)
@@ -742,6 +742,13 @@ class ControllerAdmin(PlanetStackBaseAdmin):
 
         return AdminFormMetaClass
 
+    def save_model(self, request, obj, form, change):
+        # update openstack connection to use this site/tenant
+        obj.save_by_user(request.user)
+                    
+    def delete_model(self, request, obj):
+        obj.delete_by_user(request.user)    
+
 class ServiceAttrAsTabInline(PlStackTabularInline):
     model = ServiceAttribute
     fields = ['name','value']
index 4b42815..67b77f5 100644 (file)
@@ -278,6 +278,13 @@ class Controller(PlCoreBase):
 
     def __unicode__(self):  return u'%s %s %s' % (self.name, self.backend_type, self.version)
 
+    def can_update(self, user):
+        if user.is_readonly:
+            return False
+        if user.is_admin:
+            return True
+        return False
+
 class SiteDeployment(PlCoreBase):
     objects = ControllerLinkManager()
     deleted_objects = ControllerLinkDeletionManager()