fix bug in RoleTeamsList

This commit is contained in:
AlanCoding
2016-06-11 18:04:05 -04:00
parent 3e97bdae7f
commit 7f38227e11
2 changed files with 27 additions and 3 deletions

View File

@@ -3786,6 +3786,11 @@ class RoleTeamsList(ListAPIView):
# XXX: Need to pull in can_attach and can_unattach kinda code from SubListCreateAttachDetachAPIView
role = Role.objects.get(pk=self.kwargs['pk'])
team = Team.objects.get(pk=sub_id)
from awx.main.access import RoleAccess
access = RoleAccess(request.user)
if access.can_attach(role, team, 'members', {"id": role.pk}, skip_sub_obj_read_check=False):
raise PermissionDenied()
if request.data.get('disassociate', None):
team.member_role.children.remove(role)
else: