Skip to content

Commit

Permalink
fix: allow all users to fetch stocks
Browse files Browse the repository at this point in the history
  • Loading branch information
cemgungor1 committed Dec 16, 2024
1 parent 2fd3981 commit 511f2ae
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion backend/marketfeed/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 511f2ae

Please sign in to comment.