From 511f2ae27d5fdb42d740230de8ceec358a84e643 Mon Sep 17 00:00:00 2001 From: cemgungor1 Date: Mon, 16 Dec 2024 18:16:49 +0300 Subject: [PATCH] fix: allow all users to fetch stocks --- backend/marketfeed/views.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/backend/marketfeed/views.py b/backend/marketfeed/views.py index 0f9a2cc8..03fbfadf 100644 --- a/backend/marketfeed/views.py +++ b/backend/marketfeed/views.py @@ -72,7 +72,13 @@ def destroy(self, request, pk=None): class StockViewSet(viewsets.ModelViewSet): queryset = Stock.objects.all() serializer_class = StockSerializer - permission_classes = [permissions.IsAuthenticatedOrReadOnly] + + def get_permissions(self): + if self.action == "create" or self.action == "destroy" or self.action == "update" or self.action == "patch": + self.permission_classes = [IsAuthenticated] + else: + self.permission_classes = [AllowAny] + return super().get_permissions() def list(self, request): pagination_class = StockResultsSetPagination()