From cca8fa84904725e03fe96e66e3dbed95183a7861 Mon Sep 17 00:00:00 2001 From: Parsa Nazer Date: Wed, 29 Jan 2025 23:33:45 +0330 Subject: [PATCH] remove authentication_classes --- backend/blog/views.py | 2 -- backend/home/views.py | 1 - backend/product/views.py | 11 ++++------- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/backend/blog/views.py b/backend/blog/views.py index ea79fc9..5bd3628 100644 --- a/backend/blog/views.py +++ b/backend/blog/views.py @@ -10,7 +10,6 @@ from drf_spectacular.utils import extend_schema, OpenApiParameter, OpenApiTypes class AllBlogView(APIView): - authentication_classes = [] serializer_class = AllBlogSerilizer pagination_class = StructurePagination @extend_schema( @@ -43,7 +42,6 @@ class AllBlogView(APIView): class BlogView(APIView): - authentication_classes = [] serializer_class = BlogSerilizer def get_client_ip(self, request): diff --git a/backend/home/views.py b/backend/home/views.py index 8d78300..815a2e4 100644 --- a/backend/home/views.py +++ b/backend/home/views.py @@ -8,7 +8,6 @@ from rest_framework import status class HomeView(APIView): - authentication_classes = [] def get(self, request): dollor_object, _ = DollorModel.objects.get_or_create(unique_filed='unique') diff --git a/backend/product/views.py b/backend/product/views.py index ca9675e..260beb7 100644 --- a/backend/product/views.py +++ b/backend/product/views.py @@ -24,7 +24,6 @@ from rest_framework.permissions import AllowAny class AllCategories(APIView): serializer_class = MainCategorySerializer - authentication_classes = [] @extend_schema( # parameters=[ # OpenApiParameter( @@ -51,7 +50,6 @@ class AllCategories(APIView): class ProductView(APIView): serializer_class = ProductSerializer permission_classes = [AllowAny] - authentication_classes = [] def get(self, request, pk): product = get_object_or_404(ProductModel, id=pk) dollor_object, _ = DollorModel.objects.get_or_create(unique_filed='unique') @@ -63,7 +61,6 @@ class ProductView(APIView): class AllProductsView(APIView): serializer_class = ProductSerializer pagination_class = StructurePagination - authentication_classes = [] # Add authentication if required @extend_schema( parameters=[ @@ -172,10 +169,10 @@ class AllProductsView(APIView): products = products.filter(Q(name__icontains=search_query) | Q(description__icontains=search_query)) # Price filters - try: - price_gte = int(request.query_params.get('price_gte', None)) - price_lte = int(request.query_params.get('price_lte', None)) - except: + price_gte = request.query_params.get('price_gte', None) + price_lte = request.query_params.get('price_lte', None) + + if type(price_gte) != int or type(price_lte) != int: return Response({'detail': 'value error price_gte and price_lte should be a number'}, status=status.HTTP_400_BAD_REQUEST) if price_gte: products = products.filter(price__gte=price_gte)