first commit
This commit is contained in:
commit
3e4574dcdd
163 files changed
+3559
No files matched your search
@@ -0,0 +1,31 @@
|
||||
from django.shortcuts import render
|
||||
from rest_framework.views import APIView
|
||||
from apps.product.selector import get_all_products
|
||||
from rest_framework import serializers
|
||||
from rest_framework.response import Response
|
||||
from rest_framework import status
|
||||
from utils.tools.inline_serializer import inline_serializer
|
||||
from rest_framework.permissions import IsAuthenticated
|
||||
# Create your views here.
|
||||
|
||||
|
||||
class ProductList(APIView):
|
||||
|
||||
permission_classes = (IsAuthenticated, )
|
||||
|
||||
class OutputSerializer(serializers.Serializer):
|
||||
id = serializers.IntegerField()
|
||||
category = inline_serializer(many=False, fields={
|
||||
'name': serializers.CharField(),
|
||||
})
|
||||
name = serializers.CharField()
|
||||
desc = serializers.CharField()
|
||||
emtiyaz = serializers.IntegerField()
|
||||
get_emtiyaz = serializers.IntegerField()
|
||||
image = serializers.ImageField()
|
||||
|
||||
def get(self, request):
|
||||
products = get_all_products()
|
||||
output = self.OutputSerializer(products, many=True)
|
||||
|
||||
return Response(data=output.data, status=status.HTTP_200_OK)
|
||||
Reference in new issue
Block a user