Teams cannot be parents of Organization roles

This commit is contained in:
Wayne Witzel III 2016-06-22 11:59:40 -04:00
parent 4278330032
commit e07a06e990

View File

@ -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):