В Dajngo rest добавлена возможность получать структуру МИ ФНС по ЦОД, в frontend создан предварительный шаблон

This commit is contained in:
Andrei Filippov committed 2024-04-12 15:48:42 +03:00
1 parent 0ac19fe330
commit ec5b456d30
8 files changed
+191 -287

No files matched your search

+32 -1
View File
@@ -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
+1
View File
@@ -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'),
]
+6 -1
View File
@@ -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)
+2 -2
View File
@@ -109,7 +109,7 @@ class DictCompetencesType(models.Model):
class DictDepartment(models.Model):
id_curator = models.ForeignKey('DictEmployee', models.DO_NOTHING, db_column='id_curator', blank=True, null=True, db_comment='╚─ ъєЁрЄюЁр юЄфхыр')
id_curator = models.ForeignKey('DictEmployee', models.DO_NOTHING, db_column='id_curator', blank=True, null=True, db_comment='╚─ ъєЁрЄюЁр юЄфхыр', related_name='deps_curator')
id_chief = models.ForeignKey('DictEmployee', models.DO_NOTHING, db_column='id_chief', related_name='dictdepartment_id_chief_set', blank=True, null=True, db_comment='╚─ эрўры№эшър юЄфхыр')
name = models.CharField(max_length=500, db_comment='═рчтрэшх юЄфхыр')
deleted = models.IntegerField(db_comment='╠рЁъх єфрыхэш  чряшёш')
@@ -127,7 +127,7 @@ class DictDepartment(models.Model):
class DictEmployee(models.Model):
id = models.PositiveIntegerField(primary_key=True, db_comment='╥рсхы№э√щ эюьхЁ')
id_dict_department = models.ForeignKey(DictDepartment, models.DO_NOTHING, db_column='id_dict_department', db_comment='╚─ юЄфхыр, т ъюЄюЁюь ЁрсюЄрхЄ ёюЄЁєфэшъ')
id_dict_position = models.ForeignKey('DictPosition', models.DO_NOTHING, db_column='id_dict_position', db_comment='╚─ чрэшьрхьющ фюыцэюёЄш')
id_dict_position = models.ForeignKey('DictPosition', models.DO_NOTHING, db_column='id_dict_position', db_comment='╚─ чрэшьрхьющ фюыцэюёЄш', related_name='ord_position')
login = models.CharField(max_length=100, blank=True, null=True, db_comment='ыюушэ(sAMAccountName)')
password = models.CharField(max_length=100, blank=True, null=True, db_comment='╧рЁюы№ фы  тїюфр эр яюЁЄры')
fio = models.CharField(db_column='FIO', max_length=300, blank=True, null=True, db_comment='╘╚╬(cn)') # Field name made lowercase.