38 lines
1.2 KiB
Python
38 lines
1.2 KiB
Python
from django.shortcuts import render
|
|
from rest_framework import response
|
|
from rest_framework import serializers
|
|
from rest_framework.views import APIView
|
|
from rest_framework.generics import ListAPIView
|
|
from apps.emtiyazat.models import Emtiyazat as EmtiyazatModel
|
|
from utils.standard_pagination import StandardPagination
|
|
from utils.tools.inline_serializer import inline_serializer
|
|
from apps.emtiyazat.selector import get_arzesh_emtiyaz
|
|
from rest_framework.response import Response
|
|
# Create your views here.
|
|
|
|
|
|
class RetrieveArzeshEmtiyaz(APIView):
|
|
def get(self, request):
|
|
arzesh_emtiyaz = get_arzesh_emtiyaz()
|
|
return Response({'arzesh_emtiyaz': arzesh_emtiyaz})
|
|
|
|
|
|
class ListEmtiyazatApiview(ListAPIView):
|
|
|
|
class OuputSerializer(serializers.ModelSerializer):
|
|
|
|
project = inline_serializer(many=False, fields={
|
|
'id': serializers.IntegerField(),
|
|
'factor_price': serializers.IntegerField()
|
|
})
|
|
|
|
class Meta:
|
|
model = EmtiyazatModel
|
|
fields = "__all__"
|
|
|
|
serializer_class = OuputSerializer
|
|
pagination_class = StandardPagination
|
|
|
|
def get_queryset(self):
|
|
cuser = self.request.user
|
|
return EmtiyazatModel.objects.filter(cuser=cuser) |