mirror of
https://github.com/ansible/awx.git
synced 2026-03-11 14:39:30 -02:30
Teams cannot be parents of Organization roles
This commit is contained in:
@@ -875,6 +875,13 @@ class TeamRolesList(SubListCreateAttachDetachAPIView):
|
|||||||
if not sub_id:
|
if not sub_id:
|
||||||
data = dict(msg="Role 'id' field is missing.")
|
data = dict(msg="Role 'id' field is missing.")
|
||||||
return Response(data, status=status.HTTP_400_BAD_REQUEST)
|
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)
|
return super(TeamRolesList, self).post(request, *args, **kwargs)
|
||||||
|
|
||||||
class TeamObjectRolesList(SubListAPIView):
|
class TeamObjectRolesList(SubListAPIView):
|
||||||
@@ -3715,6 +3722,11 @@ class RoleTeamsList(ListAPIView):
|
|||||||
return Response(data, status=status.HTTP_400_BAD_REQUEST)
|
return Response(data, status=status.HTTP_400_BAD_REQUEST)
|
||||||
|
|
||||||
role = Role.objects.get(pk=self.kwargs['pk'])
|
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)
|
team = Team.objects.get(pk=sub_id)
|
||||||
action = 'attach'
|
action = 'attach'
|
||||||
if request.data.get('disassociate', None):
|
if request.data.get('disassociate', None):
|
||||||
|
|||||||
Reference in New Issue
Block a user