From 04ef0b7d3523a1afff77d04a5b259f9f24bf8fd1 Mon Sep 17 00:00:00 2001 From: Samuel Gaist <samuel.gaist@idiap.ch> Date: Thu, 23 Apr 2020 16:32:40 +0200 Subject: [PATCH] [team][api] Implement get_object in place of get_queryset for TeamDetailView This view only concerns one object at a time --- beat/web/team/api.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/beat/web/team/api.py b/beat/web/team/api.py index 531b19c59..7d04b0ac8 100644 --- a/beat/web/team/api.py +++ b/beat/web/team/api.py @@ -102,7 +102,7 @@ class TeamDetailView(CommonContextMixin, generics.RetrieveUpdateDestroyAPIView): self.permission_classes.append(IsOwner) return super(TeamDetailView, self).get_permissions() - def get_queryset(self): + def get_object(self): owner_name = self.kwargs.get("owner_name") team_name = self.kwargs.get("team_name") @@ -118,12 +118,12 @@ class TeamDetailView(CommonContextMixin, generics.RetrieveUpdateDestroyAPIView): return super(TeamDetailView, self).get_serializer(*args, **kwargs) def get(self, request, owner_name, team_name): - team = self.get_queryset() + team = self.get_object() serializer = self.serializer_class(team, context={"user": request.user}) return Response(serializer.data) def delete(self, request, owner_name, team_name): - team = self.get_queryset() + team = self.get_object() # Check that the team can still be deleted if not (team.deletable()): @@ -136,7 +136,7 @@ class TeamDetailView(CommonContextMixin, generics.RetrieveUpdateDestroyAPIView): return Response(status=status.HTTP_204_NO_CONTENT) def update(self, request, owner_name, team_name): - team = self.get_queryset() + team = self.get_object() self.check_object_permissions(request, team) serializer = self.writing_serializer_class( -- GitLab