Cleanup user permissions check, fix bug to allow admin to change own username, first_name and last_name.

This commit is contained in:
Chris Church
2013-06-28 23:07:45 -04:00
parent 775ae688f8
commit e5b827944e
4 changed files with 27 additions and 37 deletions

View File

@@ -130,10 +130,11 @@ class UserAccess(BaseAccess):
def can_change(self, obj, data):
# A user can be changed if they are themselves, or by org admins or
# superusers.
if self.user.is_superuser:
return True
if self.user == obj:
return 'partial'
return bool(self.user.is_superuser or
obj.organizations.filter(admins__in=[self.user]).count())
return bool(obj.organizations.filter(admins__in=[self.user]).count())
def can_delete(self, obj):
return bool(self.user.is_superuser or