feat [P-281]: переделана шапка, список отделов получен и отрисован в селекте
This commit is contained in:
1 parent
cbd21e1985
commit
a70267d4a2
5 files changed
+118
-29
No files matched your search
@@ -70,4 +70,5 @@ urlpatterns = [
|
||||
path('api/safety/', include('safety.urls')),
|
||||
path('api/tests/', include('tests.urls')),
|
||||
path('api/vote/', include('vote.urls')),
|
||||
path('api/userauth/', include('userauth.urls')),
|
||||
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||
@@ -135,3 +135,10 @@ class InfoUserCardSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = DictEmployee
|
||||
fields = ['department', 'fio', 'post', 'email', 'tel', 'room', 'login', 'familyname', 'name', 'parentname', 'id']
|
||||
|
||||
|
||||
|
||||
class DepartmentsSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = DictDepartment
|
||||
fields = '__all__'
|
||||
@@ -0,0 +1,6 @@
|
||||
from django.urls import path
|
||||
from .views import *
|
||||
|
||||
urlpatterns = [
|
||||
path('getdepartments', GetDepartment.as_view(), name= "GetDepartment")
|
||||
]
|
||||
@@ -1,3 +1,16 @@
|
||||
from django.shortcuts import render
|
||||
from .models import DictDepartment
|
||||
from .serializers import DepartmentsSerializer
|
||||
from rest_framework.permissions import AllowAny, IsAuthenticated
|
||||
from rest_framework.views import APIView
|
||||
from rest_framework.response import Response
|
||||
|
||||
# Create your views here.
|
||||
class GetDepartment(APIView):
|
||||
permission_classes = (AllowAny,)
|
||||
"""
|
||||
Получаем отделы
|
||||
"""
|
||||
def get(self,request):
|
||||
department = DictDepartment.objects.all()
|
||||
|
||||
return Response(DepartmentsSerializer(department, many=True).data)
|
||||
Reference in new issue
Block a user