1
0
mirror of https://github.com/ansible/awx.git synced 2024-10-31 23:51:09 +03:00

fix 500 errors for credential and role lists

This commit is contained in:
Wayne Witzel III 2016-04-06 16:58:36 -04:00
parent 01d323fd06
commit 1da9ee5e6c

View File

@ -1053,7 +1053,7 @@ class UserTeamsList(ListAPIView):
serializer_class = TeamSerializer
def get_queryset(self):
u = User.objects.get(pk=self.kwargs['pk'])
u = get_object_or_404(User, pk=self.kwargs['pk'])
if not self.request.user.can_access(User, 'read', u):
raise PermissionDenied()
return Team.accessible_objects(self.request.user, {'read': True}).filter(member_role__members=u)
@ -1229,7 +1229,7 @@ class UserCredentialsList(CredentialList):
serializer_class = CredentialSerializer
def get_queryset(self):
user = User.objects.get(pk=self.kwargs['pk'])
user = get_object_or_404(User,pk=self.kwargs['pk'])
if not self.request.user.can_access(User, 'read', user):
raise PermissionDenied()
@ -1249,7 +1249,7 @@ class TeamCredentialsList(CredentialList):
serializer_class = CredentialSerializer
def get_queryset(self):
team = Team.objects.get(pk=self.kwargs['pk'])
team = get_object_or_404(Team, pk=self.kwargs['pk'])
if not self.request.user.can_access(Team, 'read', team):
raise PermissionDenied()
@ -3496,7 +3496,7 @@ class RoleTeamsList(ListAPIView):
def get_queryset(self):
# TODO: Check
role = Role.objects.get(pk=self.kwargs['pk'])
role = get_object_or_404(Role, pk=self.kwargs['pk'])
return Team.objects.filter(member_role__children=role)
def post(self, request, pk, *args, **kwargs):