commit 63228923a726d9a208058c0e98194956f708d4ad
Author: Mikan <72257910+Mikan-DS@users.noreply.github.com>
Date: Sun May 18 19:19:16 2025 +0300
config
diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..13566b8
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml
new file mode 100644
index 0000000..105ce2d
--- /dev/null
+++ b/.idea/inspectionProfiles/profiles_settings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..ec45899
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..1ead0ee
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/tisbiProFi.iml b/.idea/tisbiProFi.iml
new file mode 100644
index 0000000..7608a92
--- /dev/null
+++ b/.idea/tisbiProFi.iml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/core/__init__.py b/core/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/core/admin.py b/core/admin.py
new file mode 100644
index 0000000..8c38f3f
--- /dev/null
+++ b/core/admin.py
@@ -0,0 +1,3 @@
+from django.contrib import admin
+
+# Register your models here.
diff --git a/core/apps.py b/core/apps.py
new file mode 100644
index 0000000..8115ae6
--- /dev/null
+++ b/core/apps.py
@@ -0,0 +1,6 @@
+from django.apps import AppConfig
+
+
+class CoreConfig(AppConfig):
+ default_auto_field = 'django.db.models.BigAutoField'
+ name = 'core'
diff --git a/core/migrations/__init__.py b/core/migrations/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/core/mixins.py b/core/mixins.py
new file mode 100644
index 0000000..126da32
--- /dev/null
+++ b/core/mixins.py
@@ -0,0 +1,15 @@
+from django.db import models
+
+class ContactMixin(models.Model):
+ first_name = models.CharField(max_length=100, verbose_name="Имя")
+ last_name = models.CharField(max_length=100, verbose_name="Фамилия")
+ middle_name = models.CharField(max_length=100, blank=True, null=True, verbose_name="Отчество")
+ phone = models.CharField(max_length=20, blank=True, null=True, verbose_name="Телефон")
+ email = models.EmailField(blank=True, null=True, verbose_name="Почта")
+
+ def __str__(self):
+ return f"{self.last_name} {self.first_name}"
+
+ class Meta:
+ abstract = True
+
diff --git a/core/models.py b/core/models.py
new file mode 100644
index 0000000..e69de29
diff --git a/core/tests.py b/core/tests.py
new file mode 100644
index 0000000..7ce503c
--- /dev/null
+++ b/core/tests.py
@@ -0,0 +1,3 @@
+from django.test import TestCase
+
+# Create your tests here.
diff --git a/core/views.py b/core/views.py
new file mode 100644
index 0000000..91ea44a
--- /dev/null
+++ b/core/views.py
@@ -0,0 +1,3 @@
+from django.shortcuts import render
+
+# Create your views here.
diff --git a/manage.py b/manage.py
new file mode 100644
index 0000000..a0a13a1
--- /dev/null
+++ b/manage.py
@@ -0,0 +1,22 @@
+#!/usr/bin/env python
+"""Django's command-line utility for administrative tasks."""
+import os
+import sys
+
+
+def main():
+ """Run administrative tasks."""
+ os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'tisbiProFi.settings')
+ try:
+ from django.core.management import execute_from_command_line
+ except ImportError as exc:
+ raise ImportError(
+ "Couldn't import Django. Are you sure it's installed and "
+ "available on your PYTHONPATH environment variable? Did you "
+ "forget to activate a virtual environment?"
+ ) from exc
+ execute_from_command_line(sys.argv)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/requirements.txt b/requirements.txt
new file mode 100644
index 0000000..387a9eb
--- /dev/null
+++ b/requirements.txt
@@ -0,0 +1 @@
+django~=4.2.21
\ No newline at end of file
diff --git a/tisbiProFi/__init__.py b/tisbiProFi/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/tisbiProFi/asgi.py b/tisbiProFi/asgi.py
new file mode 100644
index 0000000..27c3220
--- /dev/null
+++ b/tisbiProFi/asgi.py
@@ -0,0 +1,16 @@
+"""
+ASGI config for tisbiProFi project.
+
+It exposes the ASGI callable as a module-level variable named ``application``.
+
+For more information on this file, see
+https://docs.djangoproject.com/en/4.2/howto/deployment/asgi/
+"""
+
+import os
+
+from django.core.asgi import get_asgi_application
+
+os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'tisbiProFi.settings')
+
+application = get_asgi_application()
diff --git a/tisbiProFi/settings.py b/tisbiProFi/settings.py
new file mode 100644
index 0000000..5e4290a
--- /dev/null
+++ b/tisbiProFi/settings.py
@@ -0,0 +1,146 @@
+"""
+Django settings for tisbiProFi project.
+
+Generated by 'django-admin startproject' using Django 4.2.21.
+
+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/
+"""
+import os
+from pathlib import Path
+
+# Build paths inside the project like this: BASE_DIR / 'subdir'.
+BASE_DIR = Path(__file__).resolve().parent.parent
+
+
+# Quick-start development settings - unsuitable for production
+# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/
+
+# SECURITY WARNING: keep the secret key used in production secret!
+SECRET_KEY = 'django-insecure-g*su%0=3d!dh^d#!@f1xow-@v#fuwr$#rsvl!if^r002s1=!t8'
+
+# SECURITY WARNING: don't run with debug turned on in production!
+DEBUG = bool(os.environ.get('LOCALDEV', False))
+
+ALLOWED_HOSTS = [
+ 'localhost',
+]
+
+
+# Application definition
+
+INSTALLED_APPS = [
+ 'django.contrib.admin',
+ 'django.contrib.auth',
+ 'django.contrib.contenttypes',
+ 'django.contrib.sessions',
+ 'django.contrib.messages',
+ 'django.contrib.staticfiles',
+ "core.apps.CoreConfig",
+ 'users.apps.UsersConfig',
+]
+
+MIDDLEWARE = [
+ 'django.middleware.security.SecurityMiddleware',
+ 'django.contrib.sessions.middleware.SessionMiddleware',
+ 'django.middleware.common.CommonMiddleware',
+ 'django.middleware.csrf.CsrfViewMiddleware',
+ 'django.contrib.auth.middleware.AuthenticationMiddleware',
+ 'django.contrib.messages.middleware.MessageMiddleware',
+ 'django.middleware.clickjacking.XFrameOptionsMiddleware',
+]
+
+ROOT_URLCONF = 'tisbiProFi.urls'
+
+TEMPLATES = [
+ {
+ 'BACKEND': 'django.template.backends.django.DjangoTemplates',
+ 'DIRS': [BASE_DIR / 'templates']
+ ,
+ '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 = 'tisbiProFi.wsgi.application'
+
+
+# Database
+# https://docs.djangoproject.com/en/4.2/ref/settings/#databases
+
+if not DEBUG:
+ DATABASES = {
+ 'default': {
+ 'ENGINE': 'django.db.backends.postgresql',
+ 'NAME': os.getenv('DB_NAME'),
+ 'USER': os.getenv('DB_USER'),
+ 'PASSWORD': os.getenv('DB_PASSWORD'),
+ 'HOST': os.getenv('DB_HOST', 'db'), # 'db' - имя сервиса в Docker Compose
+ 'PORT': os.getenv('DB_PORT', '5432'),
+ }
+ }
+else:
+ DATABASES = {
+ 'default': {
+ 'ENGINE': 'django.db.backends.sqlite3',
+ 'NAME': BASE_DIR / 'db.sqlite3',
+ }
+ }
+
+
+# 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',
+ },
+]
+
+
+# Internationalization
+# https://docs.djangoproject.com/en/4.2/topics/i18n/
+
+LANGUAGE_CODE = 'ru-ru'
+
+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/'
+STATIC_ROOT = BASE_DIR / 'static'
+
+MEDIA_URL = '/media/'
+MEDIA_ROOT = BASE_DIR / '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'
+
+AUTH_USER_MODEL = "users.UserAccount"
diff --git a/tisbiProFi/urls.py b/tisbiProFi/urls.py
new file mode 100644
index 0000000..508d059
--- /dev/null
+++ b/tisbiProFi/urls.py
@@ -0,0 +1,22 @@
+"""
+URL configuration for tisbiProFi project.
+
+The `urlpatterns` list routes URLs to views. For more information please see:
+ https://docs.djangoproject.com/en/4.2/topics/http/urls/
+Examples:
+Function views
+ 1. Add an import: from my_app import views
+ 2. Add a URL to urlpatterns: path('', views.home, name='home')
+Class-based views
+ 1. Add an import: from other_app.views import Home
+ 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
+Including another URLconf
+ 1. Import the include() function: from django.urls import include, path
+ 2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
+"""
+from django.contrib import admin
+from django.urls import path
+
+urlpatterns = [
+ path('admin/', admin.site.urls),
+]
diff --git a/tisbiProFi/wsgi.py b/tisbiProFi/wsgi.py
new file mode 100644
index 0000000..75a2c8a
--- /dev/null
+++ b/tisbiProFi/wsgi.py
@@ -0,0 +1,16 @@
+"""
+WSGI config for tisbiProFi project.
+
+It exposes the WSGI callable as a module-level variable named ``application``.
+
+For more information on this file, see
+https://docs.djangoproject.com/en/4.2/howto/deployment/wsgi/
+"""
+
+import os
+
+from django.core.wsgi import get_wsgi_application
+
+os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'tisbiProFi.settings')
+
+application = get_wsgi_application()
diff --git a/users/__init__.py b/users/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/users/admin.py b/users/admin.py
new file mode 100644
index 0000000..8c38f3f
--- /dev/null
+++ b/users/admin.py
@@ -0,0 +1,3 @@
+from django.contrib import admin
+
+# Register your models here.
diff --git a/users/apps.py b/users/apps.py
new file mode 100644
index 0000000..72b1401
--- /dev/null
+++ b/users/apps.py
@@ -0,0 +1,6 @@
+from django.apps import AppConfig
+
+
+class UsersConfig(AppConfig):
+ default_auto_field = 'django.db.models.BigAutoField'
+ name = 'users'
diff --git a/users/migrations/0001_initial.py b/users/migrations/0001_initial.py
new file mode 100644
index 0000000..f9538e4
--- /dev/null
+++ b/users/migrations/0001_initial.py
@@ -0,0 +1,51 @@
+# Generated by Django 4.2.21 on 2025-05-14 16:31
+
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+ initial = True
+
+ dependencies = [
+ ('auth', '0012_alter_user_first_name_max_length'),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name='Role',
+ fields=[
+ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('name', models.CharField(max_length=20, unique=True, verbose_name='Название роли')),
+ ],
+ options={
+ 'verbose_name': 'Роль',
+ 'verbose_name_plural': 'Роли',
+ },
+ ),
+ migrations.CreateModel(
+ name='UserAccount',
+ fields=[
+ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('password', models.CharField(max_length=128, verbose_name='password')),
+ ('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')),
+ ('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')),
+ ('first_name', models.CharField(max_length=100, verbose_name='Имя')),
+ ('last_name', models.CharField(max_length=100, verbose_name='Фамилия')),
+ ('middle_name', models.CharField(blank=True, max_length=100, null=True, verbose_name='Отчество')),
+ ('phone', models.CharField(blank=True, max_length=20, null=True, verbose_name='Телефон')),
+ ('email', models.EmailField(blank=True, max_length=254, null=True, verbose_name='Почта')),
+ ('username', models.CharField(max_length=150, unique=True, verbose_name='Имя пользователя')),
+ ('is_active', models.BooleanField(default=True, verbose_name='Активен')),
+ ('is_staff', models.BooleanField(default=False, verbose_name='Сотрудник')),
+ ('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.group', verbose_name='groups')),
+ ('role', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='users.role', verbose_name='Роль')),
+ ('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.permission', verbose_name='user permissions')),
+ ],
+ options={
+ 'verbose_name': 'Пользователь',
+ 'verbose_name_plural': 'Пользователи',
+ },
+ ),
+ ]
diff --git a/users/migrations/__init__.py b/users/migrations/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/users/models.py b/users/models.py
new file mode 100644
index 0000000..094b7da
--- /dev/null
+++ b/users/models.py
@@ -0,0 +1,48 @@
+from django.contrib.auth.models import AbstractBaseUser, BaseUserManager, PermissionsMixin
+from django.db import models
+
+from core.mixins import ContactMixin
+
+
+class Role(models.Model):
+ name = models.CharField(max_length=20, unique=True, verbose_name='Название роли')
+
+ def __str__(self):
+ return self.name
+
+ class Meta:
+ verbose_name = 'Роль'
+ verbose_name_plural = 'Роли'
+
+class UserAccountManager(BaseUserManager):
+ def create_user(self, username, password=None, role=None, **extra_fields):
+ if not username:
+ raise ValueError('Имя пользователя должно быть указано')
+ user = self.model(username=username, role=role, **extra_fields)
+ user.set_password(password)
+ user.save(using=self._db)
+ return user
+
+ def create_superuser(self, username, password=None, **extra_fields):
+ admin_role, _ = Role.objects.get_or_create(name='admin')
+ extra_fields.setdefault('is_staff', True)
+ extra_fields.setdefault('is_superuser', True)
+ return self.create_user(username, password, role=admin_role, **extra_fields)
+
+class UserAccount(ContactMixin, AbstractBaseUser, PermissionsMixin):
+ username = models.CharField(max_length=150, unique=True, verbose_name='Имя пользователя')
+ role = models.ForeignKey(Role, on_delete=models.SET_NULL, null=True, blank=True, verbose_name='Роль')
+ is_active = models.BooleanField(default=True, verbose_name='Активен')
+ is_staff = models.BooleanField(default=False, verbose_name='Сотрудник')
+
+ objects = UserAccountManager()
+
+ USERNAME_FIELD = 'username'
+ REQUIRED_FIELDS = []
+
+ def __str__(self):
+ return self.username+" ("+ContactMixin.__str__(self)+")"
+
+ class Meta:
+ verbose_name = 'Пользователь'
+ verbose_name_plural = 'Пользователи'
\ No newline at end of file
diff --git a/users/tests.py b/users/tests.py
new file mode 100644
index 0000000..7ce503c
--- /dev/null
+++ b/users/tests.py
@@ -0,0 +1,3 @@
+from django.test import TestCase
+
+# Create your tests here.
diff --git a/users/views.py b/users/views.py
new file mode 100644
index 0000000..91ea44a
--- /dev/null
+++ b/users/views.py
@@ -0,0 +1,3 @@
+from django.shortcuts import render
+
+# Create your views here.