add helper decorator to ensure signleton roles see the proper role list

This commit is contained in:
Wayne Witzel III
2016-07-01 10:38:02 -04:00
parent 47893613a2
commit 16bc0cdf0b
2 changed files with 20 additions and 6 deletions

View File

@@ -1193,12 +1193,6 @@ class UserRolesList(SubListCreateAttachDetachAPIView):
raise PermissionDenied()
content_type = ContentType.objects.get_for_model(User)
sys_admin = Role.singleton(ROLE_SINGLETON_SYSTEM_ADMINISTRATOR)
sys_audit = Role.singleton(ROLE_SINGLETON_SYSTEM_AUDITOR)
if self.request.user in sys_admin or self.request.user in sys_audit:
return u.roles.all().exclude(content_type=content_type, object_id=u.id)
return Role.filter_visible_roles(self.request.user, u.roles.all()) \
.exclude(content_type=content_type, object_id=u.id)