do not allow tower group delete or name change

* DO allow policy changes and other attribute changes
This commit is contained in:
chris meyers
2018-03-21 15:45:52 -04:00
parent e58038b056
commit 305ef6fa7e
4 changed files with 22 additions and 9 deletions

View File

@@ -231,8 +231,10 @@ class IsSuperUser(permissions.BasePermission):
class InstanceGroupTowerPermission(ModelAccessPermission):
def has_object_permission(self, request, view, obj):
if request.method not in permissions.SAFE_METHODS:
if obj.name == "tower":
return False
if request.method == 'DELETE' and obj.name == "tower":
return False
if request.method in ['PATCH', 'PUT'] and obj.name == 'tower' and \
request and request.data and request.data.get('name', '') != 'tower':
return False
return super(InstanceGroupTowerPermission, self).has_object_permission(request, view, obj)