Skip to content

Commit

Permalink
Merge pull request #533 from bounswe/fix/BE-stock-allow-get
Browse files Browse the repository at this point in the history
Allow all users to fetch stocks
  • Loading branch information
m-erkam authored Dec 16, 2024
2 parents 2fd3981 + 511f2ae commit 9f57fb0
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 9f57fb0

Please sign in to comment.