В Dajngo rest добавлена возможность получать структуру МИ ФНС по ЦОД, в frontend создан предварительный шаблон
This commit is contained in:
1 parent
0ac19fe330
commit
ec5b456d30
8 files changed
+191
-287
No files matched your search
@@ -1,5 +1,6 @@
|
||||
from rest_framework import serializers
|
||||
from .models import *
|
||||
from userauth.models import *
|
||||
|
||||
# Сериализатор модели StateSize (Штатная численность)
|
||||
class StateSizeSerializer(serializers.ModelSerializer):
|
||||
@@ -20,4 +21,34 @@ class InspectionDirectionsSerializer(serializers.ModelSerializer):
|
||||
|
||||
class Meta:
|
||||
model = InspectionDirections
|
||||
fields =['id', 'direction_title', 'icon_name',]
|
||||
fields =['id', 'direction_title', 'icon_name',]
|
||||
|
||||
|
||||
# Сериализаторы структуры инспекции
|
||||
class ChiefsDepsSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = DictEmployee
|
||||
fields = [ "id","login","fio","post","room"]
|
||||
|
||||
|
||||
# Основной сериализатор структуры инспекции
|
||||
class StructureSerializer(ChiefsDepsSerializer):
|
||||
deps = serializers.SerializerMethodField('get_deps',)
|
||||
class Meta:
|
||||
model = DictEmployee
|
||||
fields = '__all__'
|
||||
|
||||
|
||||
def get_deps(self, obj):
|
||||
return DepsSerializer(obj.deps_curator.all(), many=True).data
|
||||
|
||||
|
||||
class DepsSerializer(serializers.ModelSerializer):
|
||||
chief_deps =serializers.SerializerMethodField('get_chief_deps')
|
||||
class Meta:
|
||||
model = DictDepartment
|
||||
fields = '__all__'
|
||||
|
||||
def get_chief_deps(self, obj):
|
||||
return ChiefsDepsSerializer(obj.id_chief).data
|
||||
|
||||
@@ -7,4 +7,5 @@ urlpatterns = [
|
||||
path('getfactsize/', GetFactSize.as_view(), name='getfactsize'),
|
||||
path('getstatesize/', GetStateSize.as_view(), name='getstatesize'),
|
||||
path('getinspectiondirections/', GetInspectionDirections.as_view(), name='getinspectiondirections'),
|
||||
path('getstructure/', GetStructure.as_view(), name='getstructure'),
|
||||
]
|
||||
@@ -1,6 +1,6 @@
|
||||
from rest_framework.generics import ListAPIView
|
||||
from django.db.models import Q
|
||||
from userauth.models import DictEmployee
|
||||
from userauth.models import DictEmployee, DictPosition
|
||||
from datetime import date
|
||||
from .models import *
|
||||
from .serializers import *
|
||||
@@ -24,3 +24,8 @@ class GetInspectionDirections(ListAPIView):
|
||||
serializer_class = InspectionDirectionsSerializer
|
||||
# отключает вывод информации о пагинации(count,previous,next, results)
|
||||
paginator = None
|
||||
|
||||
class GetStructure(ListAPIView):
|
||||
def get(self, request):
|
||||
queryset = DictEmployee.objects.filter(id_dict_position__order_position__lte = 2, deleted=0).order_by('id_dict_position__order_position')
|
||||
return Response(StructureSerializer(queryset, many=True).data)
|
||||
Reference in new issue
Block a user