Skip to content

Commit

Permalink
Fix view user
Browse files Browse the repository at this point in the history
  • Loading branch information
evgeniazagorodnykh committed Feb 14, 2024
1 parent fdcc867 commit a4318e9
Showing 1 changed file with 0 additions and 17 deletions.
17 changes: 0 additions & 17 deletions backend/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,6 @@ def get_permissions(self):
self.permission_classes = [IsAuthenticated]
return super().get_permissions()

def get_serializer_context(self):
context = super().get_serializer_context()
user = self.request.user
if self.action == "me":
subscriber = self.request.user
else:
subscriber = User.objects.get(id=self.kwargs.get('id'))
context.update({
"sub_user": user,
"subscriber": subscriber
})
return context

@action(
methods=['GET'],
detail=False,
Expand Down Expand Up @@ -203,14 +190,10 @@ class SubscriptionViewSet(CreateDestroyViewSet):
permission_classes = [IsAuthenticated]

def get_serializer_context(self):
user = self.request.user
subscriber = get_object_or_404(User, id=self.kwargs.get('id'))
limit = self.request.GET.get('recipes_limit', None)
context = super().get_serializer_context()
context.update({
'recipes_limit': limit,
'sub_user': user,
'subscriber': subscriber
})
return context

Expand Down

0 comments on commit a4318e9

Please sign in to comment.