Merge branch '22_about_inspection' into P-13
This commit is contained in:
commit
4ec8b6188f
11 files changed
+399
-13
No files matched your search
+1
-1
@@ -2,7 +2,7 @@ env/
|
||||
/__pycache__/
|
||||
/*/__pycache__/
|
||||
/*/migrations/
|
||||
portal/settings.py
|
||||
portal/ds.py
|
||||
/front/node_modules/
|
||||
*.sqlite3
|
||||
/media/
|
||||
|
||||
@@ -1,7 +1,29 @@
|
||||
from django.contrib import admin
|
||||
from .models import *
|
||||
from userauth.models import DictDepartment
|
||||
from django.db.models import Q
|
||||
class InspectionDirectionsAdmin(admin.ModelAdmin):
|
||||
list_display=('direction_title',)
|
||||
fields=('direction_title','icon_name',)
|
||||
def get_form(self, request, obj=None, **kwargs):
|
||||
form = super().get_form(request, obj, **kwargs)
|
||||
print("form.base_fields")
|
||||
form.base_fields['direction_title'].label += " инспекции"
|
||||
return form
|
||||
|
||||
def get_queryset(self, request):
|
||||
qs = super().get_queryset(request)
|
||||
qs = qs.filter(department__isnull=True)
|
||||
return qs
|
||||
|
||||
class VacanciesAdmin(admin.ModelAdmin):
|
||||
def get_form(self, request, obj=None, **kwargs):
|
||||
form = super().get_form(request, obj, **kwargs)
|
||||
form.base_fields['department'].queryset = DictDepartment.objects.filter(~Q(name="Все сотрудники"),deleted=0)
|
||||
return form
|
||||
|
||||
admin.site.register(Vacancies,VacanciesAdmin)
|
||||
admin.site.register(StateSize)
|
||||
admin.site.register(FactSize)
|
||||
admin.site.register(InspectionDirections)
|
||||
admin.site.register(InspectionDirections, InspectionDirectionsAdmin)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from django.db import models
|
||||
|
||||
|
||||
from userauth.models import DictDepartment
|
||||
from ckeditor_uploader.fields import RichTextUploadingField
|
||||
|
||||
# Модель Штатная численность
|
||||
class StateSize(models.Model):
|
||||
@@ -24,10 +24,25 @@ class FactSize(models.Model):
|
||||
|
||||
# Модель Направление деятельности инспекции
|
||||
class InspectionDirections(models.Model):
|
||||
direction_title = models.CharField(max_length=255, verbose_name="Направление деятельности инспекции")
|
||||
icon_name = models.CharField(max_length=100, verbose_name="Название иконки", default="none" ,blank=True)
|
||||
direction_title = models.CharField(max_length=255, verbose_name="Направление деятельности")
|
||||
icon_name = models.CharField(max_length=100, verbose_name="Название иконки", default="mdi-sign-direction" ,blank=True)
|
||||
department = models.ForeignKey (DictDepartment,on_delete=models.PROTECT, null=True, blank=True, verbose_name='Отдел', related_name='department_directions')
|
||||
|
||||
class Meta:
|
||||
verbose_name = "Направление деятельности инспекции"
|
||||
verbose_name_plural = "Направление деятельности инспекции"
|
||||
verbose_name = "Направление деятельности "
|
||||
verbose_name_plural = "Направления деятельности"
|
||||
def __str__(self):
|
||||
return self.direction_title
|
||||
return self.direction_title
|
||||
|
||||
class Vacancies(models.Model):
|
||||
name=models.TextField(verbose_name="Наименование")
|
||||
department = models.ForeignKey (DictDepartment,on_delete=models.PROTECT, null=True, blank=True, verbose_name='Отдел')
|
||||
functional = RichTextUploadingField(null=True, blank= True, verbose_name='Функционал и должностные обязанности')
|
||||
requirements = RichTextUploadingField(null=True, blank= True, verbose_name='Базовые требования к соискателю')
|
||||
published = models.BooleanField(default = False, verbose_name="Опубликована")
|
||||
|
||||
class Meta:
|
||||
verbose_name = "Вакансия "
|
||||
verbose_name_plural = "Вакансии"
|
||||
def __str__(self):
|
||||
return self.name
|
||||
@@ -53,3 +53,28 @@ class DepsSerializer(serializers.ModelSerializer):
|
||||
def get_chief_deps(self, obj):
|
||||
return InfoUserCardSerializer(obj.id_chief).data
|
||||
|
||||
|
||||
class DepartmentDirectionsSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = InspectionDirections
|
||||
fields = ["id","direction_title"]
|
||||
ordering = ['direction_title']
|
||||
|
||||
|
||||
|
||||
|
||||
class DepartmentSerializerVac(serializers.ModelSerializer):
|
||||
department_directions= DepartmentDirectionsSerializer(many=True, read_only=True)
|
||||
class Meta:
|
||||
model = DictDepartment
|
||||
fields = ['id','name','department_directions']
|
||||
|
||||
|
||||
|
||||
class VacanciesSerializer(serializers.ModelSerializer):
|
||||
department = DepartmentSerializerVac(read_only=True)
|
||||
class Meta:
|
||||
model = Vacancies
|
||||
|
||||
fields = ["id", "department", "name","functional","requirements"]
|
||||
|
||||
@@ -8,4 +8,7 @@ urlpatterns = [
|
||||
path('getstatesize/', GetStateSize.as_view(), name='getstatesize'),
|
||||
path('getinspectiondirections/', GetInspectionDirections.as_view(), name='getinspectiondirections'),
|
||||
path('getstructure/', GetStructure.as_view(), name='getstructure'),
|
||||
path('getvacancy/', GetVacancies.as_view(), name='getvacancy'),
|
||||
|
||||
|
||||
]
|
||||
@@ -20,7 +20,7 @@ class GetFactSize(ListAPIView):
|
||||
|
||||
|
||||
class GetInspectionDirections(ListAPIView):
|
||||
queryset = InspectionDirections.objects.all()
|
||||
queryset = InspectionDirections.objects.filter(department__isnull=True)
|
||||
serializer_class = InspectionDirectionsSerializer
|
||||
# отключает вывод информации о пагинации(count,previous,next, results)
|
||||
paginator = None
|
||||
@@ -28,4 +28,10 @@ class GetInspectionDirections(ListAPIView):
|
||||
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','familyname')
|
||||
return Response(StructureSerializer(queryset, many=True).data)
|
||||
return Response(StructureSerializer(queryset, many=True).data)
|
||||
|
||||
|
||||
class GetVacancies(ListAPIView):
|
||||
def get(self, request):
|
||||
queryset = Vacancies.objects.filter(published=True).order_by('department__order_department')
|
||||
return Response(VacanciesSerializer(queryset, many=True).data)
|
||||
@@ -25,3 +25,4 @@ class getuserAPIView(APIView):
|
||||
|
||||
return Response(CardUserSerializer(queryset).data)
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
class Settings():
|
||||
def __init__(self) -> None:
|
||||
self.secret_key=''
|
||||
self.redis_hosts = []
|
||||
self.db = {
|
||||
|
||||
}
|
||||
|
||||
pass
|
||||
@@ -0,0 +1,284 @@
|
||||
"""
|
||||
Django settings for portal project.
|
||||
|
||||
Generated by 'django-admin startproject' using Django 4.2.3.
|
||||
|
||||
For more information on this file, see
|
||||
https://docs.djangoproject.com/en/4.2/topics/settings/
|
||||
|
||||
For the full list of settings and their values, see
|
||||
https://docs.djangoproject.com/en/4.2/ref/settings/
|
||||
"""
|
||||
|
||||
from pathlib import Path
|
||||
import os
|
||||
from .ds import Settings
|
||||
stngs = Settings()
|
||||
CORS_ORIGIN_ALLOW_ALL=True
|
||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||
|
||||
LIST_PER_PAGE=25
|
||||
SECRET_KEY=stngs.secret_key
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = True
|
||||
myDEBUG=True
|
||||
|
||||
ALLOWED_HOSTS = []
|
||||
CHANNEL_LAYERS = {
|
||||
"default": {
|
||||
"BACKEND": "channels_redis.core.RedisChannelLayer",
|
||||
"CONFIG": {
|
||||
"hosts":stngs.redis_hosts,
|
||||
},
|
||||
},
|
||||
|
||||
}
|
||||
|
||||
# Application definition
|
||||
|
||||
INSTALLED_APPS = [
|
||||
'daphne',
|
||||
'django.contrib.admin',
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
'rest_framework',
|
||||
'djoser',
|
||||
'rest_framework_simplejwt',
|
||||
'navigation.apps.NavigationConfig',
|
||||
'drf_yasg',
|
||||
'accounts',
|
||||
# 'orgmanagment',
|
||||
'corsheaders',
|
||||
'watcher.apps.WatcherConfig',
|
||||
'userauth.apps.UserauthConfig',
|
||||
'feedback.apps.FeedbackConfig',
|
||||
'general_vacation.apps.GeneralVacationConfig',
|
||||
'about_inspection.apps.AboutInspectionConfig',
|
||||
'calendar_of_events.apps.CalendarOfEventsConfig',
|
||||
'ckeditor'
|
||||
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
'django.middleware.security.SecurityMiddleware',
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'corsheaders.middleware.CorsMiddleware',
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'django.middleware.csrf.CsrfViewMiddleware',
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
# 'django.contrib.auth.middleware.RemoteUserMiddleware',
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
|
||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||
]
|
||||
AUTHENTICATION_BACKENDS = [
|
||||
# 'django.contrib.auth.backends.RemoteUserBackend',
|
||||
'accounts.backends.CustomAuth',
|
||||
'django.contrib.auth.backends.ModelBackend'
|
||||
|
||||
|
||||
|
||||
]
|
||||
REST_FRAMEWORK = {
|
||||
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
|
||||
'PAGE_SIZE': 10,
|
||||
'DEFAULT_AUTHENTICATION_CLASSES': (
|
||||
'rest_framework_simplejwt.authentication.JWTAuthentication',
|
||||
|
||||
),
|
||||
|
||||
}
|
||||
|
||||
ROOT_URLCONF = 'portal.urls'
|
||||
|
||||
TEMPLATES = [
|
||||
{
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
'DIRS': [],
|
||||
'APP_DIRS': True,
|
||||
'OPTIONS': {
|
||||
'context_processors': [
|
||||
'django.template.context_processors.debug',
|
||||
'django.template.context_processors.request',
|
||||
'django.contrib.auth.context_processors.auth',
|
||||
'django.contrib.messages.context_processors.messages',
|
||||
],
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
# WSGI_APPLICATION = 'portal.wsgi.application'
|
||||
ASGI_APPLICATION = "portal.asgi.application"
|
||||
|
||||
# Database
|
||||
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases
|
||||
|
||||
DATABASES = stngs.db
|
||||
|
||||
|
||||
# Password validation
|
||||
# https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators
|
||||
|
||||
AUTH_PASSWORD_VALIDATORS = [
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
|
||||
},
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
|
||||
},
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
|
||||
},
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
|
||||
},
|
||||
]
|
||||
AUTH_USER_MODEL = 'accounts.User'
|
||||
|
||||
# Internationalization
|
||||
# https://docs.djangoproject.com/en/4.2/topics/i18n/
|
||||
|
||||
LANGUAGE_CODE = 'ru'
|
||||
|
||||
# TIME_ZONE = 'UTC'
|
||||
TIME_ZONE = 'Europe/Moscow'
|
||||
|
||||
USE_I18N = True
|
||||
|
||||
USE_TZ = True
|
||||
|
||||
|
||||
# Static files (CSS, JavaScript, Images)
|
||||
# https://docs.djangoproject.com/en/4.2/howto/static-files/
|
||||
|
||||
|
||||
STATIC_URL = '/static/'
|
||||
STATICFILES_DIRS = (
|
||||
BASE_DIR.joinpath('static'),
|
||||
)
|
||||
# STATIC_ROOT = BASE_DIR.joinpath('static')
|
||||
CKEDITOR_UPLOAD_PATH = "uploads/"
|
||||
# Media
|
||||
MEDIA_URL = '/media/'
|
||||
MEDIA_ROOT = BASE_DIR.joinpath('media')
|
||||
# Default primary key field type
|
||||
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field
|
||||
|
||||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
||||
|
||||
from datetime import timedelta
|
||||
|
||||
|
||||
SIMPLE_JWT = {
|
||||
"ACCESS_TOKEN_LIFETIME": timedelta(minutes=30),
|
||||
"REFRESH_TOKEN_LIFETIME": timedelta(days=1),
|
||||
"ROTATE_REFRESH_TOKENS": False,
|
||||
"BLACKLIST_AFTER_ROTATION": False,
|
||||
"UPDATE_LAST_LOGIN": False,
|
||||
|
||||
"ALGORITHM": "HS256",
|
||||
"SIGNING_KEY": SECRET_KEY,
|
||||
"VERIFYING_KEY": "",
|
||||
"AUDIENCE": None,
|
||||
"ISSUER": None,
|
||||
"JSON_ENCODER": None,
|
||||
"JWK_URL": None,
|
||||
"LEEWAY": 0,
|
||||
|
||||
"AUTH_HEADER_TYPES": ("Bearer",),
|
||||
"AUTH_HEADER_NAME": "HTTP_AUTHORIZATION",
|
||||
"USER_ID_FIELD": "id",
|
||||
"USER_ID_CLAIM": "user_id",
|
||||
"USER_AUTHENTICATION_RULE": "rest_framework_simplejwt.authentication.default_user_authentication_rule",
|
||||
|
||||
"AUTH_TOKEN_CLASSES": ("rest_framework_simplejwt.tokens.AccessToken",),
|
||||
"TOKEN_TYPE_CLAIM": "token_type",
|
||||
"TOKEN_USER_CLASS": "rest_framework_simplejwt.models.TokenUser",
|
||||
|
||||
"JTI_CLAIM": "jti",
|
||||
|
||||
"SLIDING_TOKEN_REFRESH_EXP_CLAIM": "refresh_exp",
|
||||
"SLIDING_TOKEN_LIFETIME": timedelta(minutes=5),
|
||||
"SLIDING_TOKEN_REFRESH_LIFETIME": timedelta(days=1),
|
||||
|
||||
"TOKEN_OBTAIN_SERIALIZER": 'accounts.backends.MyTokenObtainPairSerializer',
|
||||
"TOKEN_REFRESH_SERIALIZER": "rest_framework_simplejwt.serializers.TokenRefreshSerializer",
|
||||
"TOKEN_VERIFY_SERIALIZER": "rest_framework_simplejwt.serializers.TokenVerifySerializer",
|
||||
"TOKEN_BLACKLIST_SERIALIZER": "rest_framework_simplejwt.serializers.TokenBlacklistSerializer",
|
||||
"SLIDING_TOKEN_OBTAIN_SERIALIZER": "rest_framework_simplejwt.serializers.TokenObtainSlidingSerializer",
|
||||
"SLIDING_TOKEN_REFRESH_SERIALIZER": "rest_framework_simplejwt.serializers.TokenRefreshSlidingSerializer",
|
||||
}
|
||||
|
||||
CKEDITOR_CONFIGS = {
|
||||
'default': {
|
||||
# 'skin': 'moono',
|
||||
# 'skin': 'office2013',
|
||||
'toolbar_Basic': [
|
||||
['Source', '-', 'Bold', 'Italic']
|
||||
],
|
||||
'toolbar_YourCustomToolbarConfig': [
|
||||
# {'name': 'document', 'items': ['Source', '-', 'Save', 'NewPage', 'Preview', 'Print', '-', 'Templates']},
|
||||
# {'name': 'clipboard', 'items': ['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo']},
|
||||
{'name': 'editing', 'items': ['Find',]},
|
||||
# {'name': 'forms',
|
||||
# 'items': ['Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton',
|
||||
# 'HiddenField']},
|
||||
# '/',
|
||||
{'name': 'basicstyles',
|
||||
'items': ['Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat']},
|
||||
|
||||
{'name': 'paragraph',
|
||||
'items': ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote', 'CreateDiv', '-',
|
||||
'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock', '-',
|
||||
# 'BidiLtr', 'BidiRtl',
|
||||
]},
|
||||
# '/',
|
||||
{'name': 'links', 'items': ['Link', 'Unlink', 'Anchor']},
|
||||
{'name': 'insert',
|
||||
'items': [ 'Table', 'HorizontalRule', 'Smiley', 'SpecialChar', 'PageBreak']},
|
||||
# 'Image', 'Flash', 'Iframe']},
|
||||
'/',
|
||||
{'name': 'styles', 'items': ['Styles', 'Format', 'Font', 'FontSize']},
|
||||
{'name': 'colors', 'items': ['TextColor', 'BGColor']},
|
||||
{'name': 'tools', 'items': ['Maximize', 'ShowBlocks']},
|
||||
# {'name': 'about', 'items': ['About']},
|
||||
# '/', # put this to force next toolbar on new line
|
||||
{'name': 'yourcustomtools', 'items': [
|
||||
# put the name of your editor.ui.addButton here
|
||||
'Preview',
|
||||
'Maximize',
|
||||
|
||||
]},
|
||||
],
|
||||
'toolbar': 'YourCustomToolbarConfig', # put selected toolbar config here
|
||||
# 'toolbarGroups': [{ 'name': 'document', 'groups': [ 'mode', 'document', 'doctools' ] }],
|
||||
# 'height': 291,
|
||||
# 'width': '100%',
|
||||
# 'filebrowserWindowHeight': 725,
|
||||
# 'filebrowserWindowWidth': 940,
|
||||
# 'toolbarCanCollapse': True,
|
||||
# 'mathJaxLib': '//cdn.mathjax.org/mathjax/2.2-latest/MathJax.js?config=TeX-AMS_HTML',
|
||||
'tabSpaces': 4,
|
||||
'extraPlugins': ','.join([
|
||||
'uploadimage', # the upload image feature
|
||||
# your extra plugins here
|
||||
'div',
|
||||
'autolink',
|
||||
'autoembed',
|
||||
'embedsemantic',
|
||||
'autogrow',
|
||||
# 'devtools',
|
||||
'widget',
|
||||
'lineutils',
|
||||
'clipboard',
|
||||
'dialog',
|
||||
'dialogui',
|
||||
'elementspath'
|
||||
]),
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
from django.contrib import admin
|
||||
from .models import *
|
||||
from django.db.models import Q
|
||||
from about_inspection.models import InspectionDirections
|
||||
# Register your models here.
|
||||
class DictEmployeeAdmin(admin.ModelAdmin):
|
||||
# A handy constant for the name of the alternate database.
|
||||
@@ -9,9 +10,25 @@ class DictEmployeeAdmin(admin.ModelAdmin):
|
||||
search_fields = ('login', 'fio',)
|
||||
list_editable=('birthdate',)
|
||||
|
||||
class DepartmentDirections(admin.TabularInline):
|
||||
model =InspectionDirections
|
||||
fields = ( 'direction_title',)
|
||||
verbose_name="Направление деятельности отдела"
|
||||
verbose_name_plural= "Направления деятельности отдела"
|
||||
can_delete = True
|
||||
# show_change_link = False
|
||||
extra = 0
|
||||
|
||||
|
||||
# class DictEmployeeAdmin(admin.ModelAdmin):
|
||||
class DictDepartmentAdmin(admin.ModelAdmin):
|
||||
readonly_fields=( 'name', 'name_from_ad')
|
||||
inlines = [DepartmentDirections]
|
||||
def get_queryset(self, request):
|
||||
qs = super().get_queryset(request)
|
||||
qs = qs.filter(deleted=0)
|
||||
return qs
|
||||
|
||||
|
||||
|
||||
admin.site.register(DictEmployee,DictEmployeeAdmin)
|
||||
admin.site.register(DictDepartment, DictDepartmentAdmin )
|
||||
@@ -109,6 +109,7 @@ class DictCompetencesType(models.Model):
|
||||
|
||||
|
||||
class DictDepartment(models.Model):
|
||||
id = models.PositiveIntegerField(primary_key=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='═рчтрэшх юЄфхыр')
|
||||
@@ -119,10 +120,13 @@ class DictDepartment(models.Model):
|
||||
order_department = models.IntegerField()
|
||||
|
||||
class Meta:
|
||||
verbose_name = "Отдел"
|
||||
verbose_name_plural = "Отделы"
|
||||
managed = False
|
||||
db_table = 'dict_department'
|
||||
db_table_comment = '╤яЁртюўэшъ юЄфхыют'
|
||||
|
||||
def __str__(self):
|
||||
return str(self.name)
|
||||
|
||||
class DictEmployee(models.Model):
|
||||
id = models.PositiveIntegerField(primary_key=True, db_comment='╥рсхы№э√щ эюьхЁ')
|
||||
|
||||
Reference in new issue
Block a user