Группировка по папкам
This commit is contained in:
1 parent
17f35a0f5d
commit
7cba2e0366
880 files changed
+11
-146079
No files matched your search
Whitespace-only changes.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,12 @@
|
||||
from django.contrib import admin
|
||||
from .models import *
|
||||
|
||||
class GeneralVacationAdmin(admin.ModelAdmin):
|
||||
fields = ('user', 'planned_date', 'count_days', 'type_of_vacation', 'start_work_period', 'end_work_period')
|
||||
list_display=('get_name', 'user', 'planned_date', 'count_days', 'type_of_vacation', 'start_work_period', 'end_work_period')
|
||||
readonly_fields=('get_name',)
|
||||
def get_name(self, obj):
|
||||
print(obj.user.fio(), '----------------obj.user.fio()')
|
||||
return obj.user.fio()
|
||||
|
||||
admin.site.register(GeneralVacation, GeneralVacationAdmin)
|
||||
@@ -0,0 +1,8 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class GeneralVacationConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'general_vacation'
|
||||
verbose_name = "Общий график отпусков"
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
from django.db import models
|
||||
from django.conf import settings
|
||||
from userauth.models import DictEmployee
|
||||
|
||||
class GeneralVacation(models.Model):
|
||||
CHOICES = (
|
||||
('os', 'Осн'),
|
||||
('nd', 'Доп н/д'),
|
||||
('vl', 'Доп в/л'),
|
||||
)
|
||||
user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.PROTECT, verbose_name='Сотрудник')
|
||||
planned_date = models.DateField(verbose_name='Запланированная дата')
|
||||
count_days = models.IntegerField(verbose_name='Кол-во дней', default=0, blank=True)
|
||||
type_of_vacation = models.CharField(max_length=300, choices = CHOICES, verbose_name='Тип отпуска')
|
||||
start_work_period = models.DateField(verbose_name='Начало рабочего периода')
|
||||
end_work_period = models.DateField(verbose_name='Конец рабочего периода')
|
||||
|
||||
class Meta:
|
||||
verbose_name = "График отпусков"
|
||||
verbose_name_plural = "График отпусков"
|
||||
|
||||
def __str__(self):
|
||||
return str(self.user)
|
||||
|
||||
def department(self):
|
||||
return DictEmployee.objects.using('user_directory').get(login=self.username).department
|
||||
@@ -0,0 +1,8 @@
|
||||
from rest_framework import serializers
|
||||
from .models import *
|
||||
|
||||
class GeneralVacationSerializer(serializers.ModelSerializer):
|
||||
|
||||
class Meta:
|
||||
model = GeneralVacation
|
||||
fields ='__all__'
|
||||
@@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
@@ -0,0 +1,7 @@
|
||||
from django.urls import path
|
||||
from .views import *
|
||||
|
||||
|
||||
urlpatterns = [
|
||||
path('generalvacation/', GeneralVacationAPIView.as_view(), name='generalvacation'),
|
||||
]
|
||||
@@ -0,0 +1,17 @@
|
||||
from rest_framework.response import Response
|
||||
import datetime
|
||||
from .serializers import *
|
||||
from .models import *
|
||||
|
||||
from rest_framework.views import APIView
|
||||
|
||||
class GeneralVacationAPIView(APIView):
|
||||
def get(self, request):
|
||||
general = GeneralVacation.objects.all()
|
||||
|
||||
# Сериализуем извлечённый набор записей
|
||||
serializer_for_basecrit = GeneralVacationSerializer(
|
||||
instance=general, # Передаём набор записей
|
||||
many=True # Указываем, что на вход подаётся именно набор записей
|
||||
)
|
||||
return Response({"Отпуск": serializer_for_basecrit.data})
|
||||
Reference in new issue
Block a user