RoleTeam and TeamRole sublist NotFound exception handling and test update

This commit is contained in:
AlanCoding
2016-07-28 11:15:08 -04:00
parent f5fa53d89a
commit 1fb173b2e5
2 changed files with 4 additions and 4 deletions

View File

@@ -879,7 +879,7 @@ class TeamRolesList(SubListCreateAttachDetachAPIView):
data = dict(msg="Role 'id' field is missing.")
return Response(data, status=status.HTTP_400_BAD_REQUEST)
role = Role.objects.get(pk=sub_id)
role = get_object_or_400(Role, 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.")
@@ -3678,7 +3678,7 @@ class RoleTeamsList(SubListAPIView):
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)
team = get_object_or_400(Team, pk=sub_id)
action = 'attach'
if request.data.get('disassociate', None):
action = 'unattach'