Merge pull request #2574 from wwitzel3/fix-race

Ensure teams cannot have org roles as children.
This commit is contained in:
Wayne Witzel III
2016-06-22 17:31:27 -04:00
committed by GitHub
2 changed files with 45 additions and 1 deletions

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 an Organization role as a child role for a Team.")
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 an Organization role as a child role for a Team.")
return Response(data, status=status.HTTP_400_BAD_REQUEST)
team = Team.objects.get(pk=sub_id)
action = 'attach'
if request.data.get('disassociate', None):