From 3b90a1bd2320fc8447f3fea00345d224f5da8623 Mon Sep 17 00:00:00 2001 From: behruz-dev Date: Thu, 4 Sep 2025 18:56:32 +0500 Subject: [PATCH] add: add new model --- core/apps/orders/urls.py | 2 +- core/apps/orders/views/supplier.py | 20 +++++++++----------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/core/apps/orders/urls.py b/core/apps/orders/urls.py index 9fc4d93..1640bfd 100644 --- a/core/apps/orders/urls.py +++ b/core/apps/orders/urls.py @@ -8,5 +8,5 @@ urlpatterns = [ path('order/list/', order_views.OrderListApiView.as_view()), path('supplier/create/', supp_views.SupplierCreateApiView.as_view()), path('supplier//', supp_views.SupplierGetApiView.as_view()), - path('supplier/list/', supp_views.SupplierListApiView.as_view()), + path('supplier/', supp_views.SupplierListApiView.as_view()), ] \ No newline at end of file diff --git a/core/apps/orders/views/supplier.py b/core/apps/orders/views/supplier.py index 679bd41..c989310 100644 --- a/core/apps/orders/views/supplier.py +++ b/core/apps/orders/views/supplier.py @@ -1,4 +1,4 @@ -from rest_framework import views, permissions +from rest_framework import views, permissions, generics from rest_framework.response import Response from core.apps.orders.models import Supplier @@ -19,19 +19,17 @@ class SupplierCreateApiView(views.APIView): return Response({'success': True, 'message': 'created'}, status=200) +class SupplierListApiView(generics.ListAPIView): + permission_classes = [permissions.IsAdminUser] + queryset = Supplier.objects.all() + serializer_class = SupplierListSerializer + pagination_class = None + + class SupplierGetApiView(views.APIView): def get(self, request, tg_id): supp = Supplier.objects.filter(tg_id=tg_id).first() if supp: return Response({'success': True}, status=200) else: - return Response({"success": False},status=404) - - -class SupplierListApiView(views.APIView): - permission_classes = [permissions.IsAdminUser] - - def get(self, request): - supp = Supplier.objects.all() - serializer = SupplierListSerializer(supp, many=True) - return Response(serializer.data, status=200) \ No newline at end of file + return Response({"success": False},status=404) \ No newline at end of file