diff --git a/db.sqlite3 b/db.sqlite3 index ac03683f2..1deac32a0 100644 Binary files a/db.sqlite3 and b/db.sqlite3 differ diff --git a/general_vacation/__init__.py b/general_vacation/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/general_vacation/admin.py b/general_vacation/admin.py new file mode 100644 index 000000000..5562a2a7f --- /dev/null +++ b/general_vacation/admin.py @@ -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) diff --git a/general_vacation/apps.py b/general_vacation/apps.py new file mode 100644 index 000000000..895639dc9 --- /dev/null +++ b/general_vacation/apps.py @@ -0,0 +1,8 @@ +from django.apps import AppConfig + + +class GeneralVacationConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'general_vacation' + verbose_name = "Общий график отпусков" + diff --git a/general_vacation/models.py b/general_vacation/models.py new file mode 100644 index 000000000..c5d1a2d37 --- /dev/null +++ b/general_vacation/models.py @@ -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 \ No newline at end of file diff --git a/general_vacation/tests.py b/general_vacation/tests.py new file mode 100644 index 000000000..7ce503c2d --- /dev/null +++ b/general_vacation/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/general_vacation/urls.py b/general_vacation/urls.py new file mode 100644 index 000000000..e69de29bb diff --git a/general_vacation/views.py b/general_vacation/views.py new file mode 100644 index 000000000..91ea44a21 --- /dev/null +++ b/general_vacation/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/portal/settings.py b/portal/settings.py index 728a4f8e9..74a32120f 100644 --- a/portal/settings.py +++ b/portal/settings.py @@ -58,7 +58,8 @@ INSTALLED_APPS = [ 'corsheaders', 'watcher.apps.WatcherConfig', 'userauth.apps.UserauthConfig', - 'feedback.apps.FeedbackConfig' + 'feedback.apps.FeedbackConfig', + 'general_vacation.apps.GeneralVacationConfig' ] diff --git a/portal/urls.py b/portal/urls.py index 1d962727f..a108a7f38 100644 --- a/portal/urls.py +++ b/portal/urls.py @@ -63,5 +63,6 @@ urlpatterns = [ path("api/navigation/",include("navigation.urls")), path('api/watcher/', include('watcher.urls')), path('api/feedback/', include('feedback.urls')), + # path('api/general_vacation/', include('general_vacation.urls')), ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) \ No newline at end of file