diff --git a/core/apps/orders/serializers/supplier.py b/core/apps/orders/serializers/supplier.py new file mode 100644 index 0000000..283f6ef --- /dev/null +++ b/core/apps/orders/serializers/supplier.py @@ -0,0 +1,11 @@ +from rest_framework import serializers + +from core.apps.orders.models import Supplier + + +class SupplierListSerializer(serializers.ModelSerializer): + class Meta: + model = Supplier + fields = [ + 'id', 'phone', 'full_name', 'tg_id' + ] \ No newline at end of file diff --git a/core/apps/orders/urls.py b/core/apps/orders/urls.py index ff9c792..9fc4d93 100644 --- a/core/apps/orders/urls.py +++ b/core/apps/orders/urls.py @@ -8,4 +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()), ] \ No newline at end of file diff --git a/core/apps/orders/views/supplier.py b/core/apps/orders/views/supplier.py index d5f6881..679bd41 100644 --- a/core/apps/orders/views/supplier.py +++ b/core/apps/orders/views/supplier.py @@ -1,7 +1,8 @@ -from rest_framework import views +from rest_framework import views, permissions from rest_framework.response import Response from core.apps.orders.models import Supplier +from core.apps.orders.serializers.supplier import SupplierListSerializer class SupplierCreateApiView(views.APIView): @@ -25,4 +26,12 @@ class SupplierGetApiView(views.APIView): return Response({'success': True}, status=200) else: return Response({"success": False},status=404) - \ No newline at end of file + + +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