remove authentication_classes

This commit is contained in:
Parsa Nazer
2025-01-29 23:33:45 +03:30
parent 0aaac1e9c8
commit cca8fa8490
3 changed files with 4 additions and 10 deletions
+4 -7
View File
@@ -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)