mirror of
https://github.com/ansible/awx.git
synced 2026-01-12 18:40:01 -03:30
Teams cannot be parents of Organization roles
This commit is contained in:
parent
4278330032
commit
e07a06e990
@ -875,6 +875,13 @@ class TeamRolesList(SubListCreateAttachDetachAPIView):
|
||||
if not sub_id:
|
||||
data = dict(msg="Role 'id' field is missing.")
|
||||
return Response(data, status=status.HTTP_400_BAD_REQUEST)
|
||||
|
||||
role = Role.objects.get(pk=sub_id)
|
||||
content_type = ContentType.objects.get_for_model(Organization)
|
||||
if role.content_type == content_type:
|
||||
data = dict(msg="You cannot assign Organization roles and child roles for Teams.")
|
||||
return Response(data, status=status.HTTP_400_BAD_REQUEST)
|
||||
|
||||
return super(TeamRolesList, self).post(request, *args, **kwargs)
|
||||
|
||||
class TeamObjectRolesList(SubListAPIView):
|
||||
@ -3715,6 +3722,11 @@ class RoleTeamsList(ListAPIView):
|
||||
return Response(data, status=status.HTTP_400_BAD_REQUEST)
|
||||
|
||||
role = Role.objects.get(pk=self.kwargs['pk'])
|
||||
content_type = ContentType.objects.get_for_model(Organization)
|
||||
if role.content_type == content_type:
|
||||
data = dict(msg="You cannot assign Organization roles and child roles for Teams.")
|
||||
return Response(data, status=status.HTTP_400_BAD_REQUEST)
|
||||
|
||||
team = Team.objects.get(pk=sub_id)
|
||||
action = 'attach'
|
||||
if request.data.get('disassociate', None):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user