# Generated by Django 4.2.7 on 2025-12-09 21:02

from django.conf import settings
import django.core.validators
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone


class Migration(migrations.Migration):
    initial = True

    dependencies = [
        ("auth", "0012_alter_user_first_name_max_length"),
    ]

    operations = [
        migrations.CreateModel(
            name="User",
            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(
                        blank=True, max_length=150, verbose_name="first name"
                    ),
                ),
                (
                    "last_name",
                    models.CharField(
                        blank=True, max_length=150, verbose_name="last name"
                    ),
                ),
                (
                    "is_staff",
                    models.BooleanField(
                        default=False,
                        help_text="Designates whether the user can log into this admin site.",
                        verbose_name="staff status",
                    ),
                ),
                (
                    "is_active",
                    models.BooleanField(
                        default=True,
                        help_text="Designates whether this user should be treated as active. Unselect this instead of deleting accounts.",
                        verbose_name="active",
                    ),
                ),
                (
                    "date_joined",
                    models.DateTimeField(
                        default=django.utils.timezone.now, verbose_name="date joined"
                    ),
                ),
                (
                    "username",
                    models.CharField(
                        blank=True,
                        max_length=150,
                        null=True,
                        unique=True,
                        verbose_name="Имя пользователя",
                    ),
                ),
                (
                    "email",
                    models.EmailField(
                        help_text="Email используется для входа в систему",
                        max_length=254,
                        unique=True,
                        verbose_name="Email",
                    ),
                ),
                (
                    "role",
                    models.CharField(
                        choices=[
                            ("mentor", "Ментор"),
                            ("client", "Клиент"),
                            ("parent", "Родитель"),
                            ("admin", "Администратор"),
                        ],
                        default="client",
                        help_text="Роль определяет права доступа в системе",
                        max_length=10,
                        verbose_name="Роль",
                    ),
                ),
                (
                    "phone",
                    models.CharField(
                        blank=True,
                        max_length=17,
                        validators=[
                            django.core.validators.RegexValidator(
                                message="Телефон должен быть в формате: '+999999999'. До 15 цифр.",
                                regex="^\\+?1?\\d{9,15}$",
                            )
                        ],
                        verbose_name="Телефон",
                    ),
                ),
                (
                    "avatar",
                    models.ImageField(
                        blank=True,
                        null=True,
                        upload_to="avatars/%Y/%m/",
                        verbose_name="Аватар",
                    ),
                ),
                (
                    "birth_date",
                    models.DateField(
                        blank=True, null=True, verbose_name="Дата рождения"
                    ),
                ),
                (
                    "bio",
                    models.TextField(blank=True, max_length=500, verbose_name="О себе"),
                ),
                (
                    "email_verified",
                    models.BooleanField(
                        default=False, verbose_name="Email подтвержден"
                    ),
                ),
                (
                    "email_verification_token",
                    models.CharField(
                        blank=True,
                        max_length=100,
                        verbose_name="Токен подтверждения email",
                    ),
                ),
                (
                    "timezone",
                    models.CharField(
                        default="Europe/Moscow",
                        max_length=50,
                        verbose_name="Часовой пояс",
                    ),
                ),
                (
                    "telegram_id",
                    models.BigIntegerField(
                        blank=True,
                        help_text="ID пользователя в Telegram для уведомлений",
                        null=True,
                        unique=True,
                        verbose_name="Telegram ID",
                    ),
                ),
                (
                    "telegram_username",
                    models.CharField(
                        blank=True,
                        help_text="Username в Telegram",
                        max_length=100,
                        verbose_name="Telegram username",
                    ),
                ),
                (
                    "country",
                    models.CharField(
                        blank=True,
                        help_text="Страна проживания пользователя (для подбора часового пояса и аналитики)",
                        max_length=100,
                        verbose_name="Страна",
                    ),
                ),
                (
                    "city",
                    models.CharField(
                        blank=True,
                        help_text="Город проживания пользователя",
                        max_length=100,
                        verbose_name="Город",
                    ),
                ),
                (
                    "language",
                    models.CharField(
                        choices=[("ru", "Русский"), ("en", "English")],
                        default="ru",
                        max_length=10,
                        verbose_name="Язык",
                    ),
                ),
                (
                    "is_blocked",
                    models.BooleanField(default=False, verbose_name="Заблокирован"),
                ),
                (
                    "blocked_reason",
                    models.TextField(blank=True, verbose_name="Причина блокировки"),
                ),
                (
                    "blocked_at",
                    models.DateTimeField(
                        blank=True, null=True, verbose_name="Дата блокировки"
                    ),
                ),
                (
                    "created_at",
                    models.DateTimeField(
                        auto_now_add=True, verbose_name="Дата создания"
                    ),
                ),
                (
                    "updated_at",
                    models.DateTimeField(auto_now=True, verbose_name="Дата обновления"),
                ),
                (
                    "last_activity",
                    models.DateTimeField(
                        blank=True, null=True, verbose_name="Последняя активность"
                    ),
                ),
                (
                    "notifications_enabled",
                    models.BooleanField(
                        default=True, verbose_name="Уведомления включены"
                    ),
                ),
                (
                    "email_notifications",
                    models.BooleanField(default=True, verbose_name="Email уведомления"),
                ),
                (
                    "telegram_notifications",
                    models.BooleanField(
                        default=False, verbose_name="Telegram уведомления"
                    ),
                ),
                (
                    "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",
                    ),
                ),
                (
                    "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": "Пользователи",
                "db_table": "users",
                "ordering": ["-created_at"],
            },
        ),
        migrations.CreateModel(
            name="Client",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "grade",
                    models.CharField(
                        blank=True, max_length=50, verbose_name="Класс/Курс"
                    ),
                ),
                (
                    "school",
                    models.CharField(
                        blank=True,
                        max_length=200,
                        verbose_name="Школа/Учебное заведение",
                    ),
                ),
                (
                    "learning_goals",
                    models.TextField(blank=True, verbose_name="Цели обучения"),
                ),
                (
                    "total_lessons",
                    models.IntegerField(default=0, verbose_name="Всего занятий"),
                ),
                (
                    "completed_lessons",
                    models.IntegerField(default=0, verbose_name="Завершенных занятий"),
                ),
                (
                    "enrollment_date",
                    models.DateField(
                        auto_now_add=True, verbose_name="Дата регистрации"
                    ),
                ),
                (
                    "created_at",
                    models.DateTimeField(
                        auto_now_add=True, verbose_name="Дата создания"
                    ),
                ),
                (
                    "updated_at",
                    models.DateTimeField(auto_now=True, verbose_name="Дата обновления"),
                ),
                (
                    "mentors",
                    models.ManyToManyField(
                        blank=True,
                        limit_choices_to={"role": "mentor"},
                        related_name="clients",
                        to=settings.AUTH_USER_MODEL,
                        verbose_name="Менторы",
                    ),
                ),
                (
                    "user",
                    models.OneToOneField(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="client_profile",
                        to=settings.AUTH_USER_MODEL,
                        verbose_name="Пользователь",
                    ),
                ),
            ],
            options={
                "verbose_name": "Клиент",
                "verbose_name_plural": "Клиенты",
                "db_table": "clients",
                "ordering": ["-created_at"],
            },
        ),
        migrations.CreateModel(
            name="Parent",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "relation_type",
                    models.CharField(
                        choices=[
                            ("mother", "Мать"),
                            ("father", "Отец"),
                            ("guardian", "Опекун"),
                            ("other", "Другое"),
                        ],
                        default="other",
                        max_length=50,
                        verbose_name="Тип родства",
                    ),
                ),
                (
                    "can_view_progress",
                    models.BooleanField(
                        default=True, verbose_name="Может просматривать прогресс"
                    ),
                ),
                (
                    "can_view_schedule",
                    models.BooleanField(
                        default=True, verbose_name="Может просматривать расписание"
                    ),
                ),
                (
                    "can_receive_reports",
                    models.BooleanField(default=True, verbose_name="Получает отчеты"),
                ),
                (
                    "created_at",
                    models.DateTimeField(
                        auto_now_add=True, verbose_name="Дата создания"
                    ),
                ),
                (
                    "updated_at",
                    models.DateTimeField(auto_now=True, verbose_name="Дата обновления"),
                ),
                (
                    "children",
                    models.ManyToManyField(
                        related_name="parents", to="users.client", verbose_name="Дети"
                    ),
                ),
                (
                    "user",
                    models.OneToOneField(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="parent_profile",
                        to=settings.AUTH_USER_MODEL,
                        verbose_name="Пользователь",
                    ),
                ),
            ],
            options={
                "verbose_name": "Родитель",
                "verbose_name_plural": "Родители",
                "db_table": "parents",
                "ordering": ["-created_at"],
            },
        ),
        migrations.CreateModel(
            name="Group",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "name",
                    models.CharField(max_length=255, verbose_name="Название группы"),
                ),
                ("description", models.TextField(blank=True, verbose_name="Описание")),
                (
                    "created_at",
                    models.DateTimeField(
                        auto_now_add=True, verbose_name="Дата создания"
                    ),
                ),
                (
                    "updated_at",
                    models.DateTimeField(auto_now=True, verbose_name="Дата обновления"),
                ),
                (
                    "mentor",
                    models.ForeignKey(
                        limit_choices_to={"role": "mentor"},
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="mentor_groups",
                        to=settings.AUTH_USER_MODEL,
                        verbose_name="Ментор",
                    ),
                ),
                (
                    "students",
                    models.ManyToManyField(
                        blank=True,
                        related_name="groups",
                        to="users.client",
                        verbose_name="Ученики",
                    ),
                ),
            ],
            options={
                "verbose_name": "Группа",
                "verbose_name_plural": "Группы",
                "db_table": "groups",
                "ordering": ["name"],
                "indexes": [
                    models.Index(
                        fields=["mentor", "name"], name="groups_mentor__a4cb36_idx"
                    )
                ],
            },
        ),
        migrations.AddIndex(
            model_name="user",
            index=models.Index(fields=["email"], name="users_email_4b85f2_idx"),
        ),
        migrations.AddIndex(
            model_name="user",
            index=models.Index(fields=["role"], name="users_role_0ace22_idx"),
        ),
        migrations.AddIndex(
            model_name="user",
            index=models.Index(fields=["telegram_id"], name="users_telegra_d76140_idx"),
        ),
        migrations.AddIndex(
            model_name="user",
            index=models.Index(fields=["created_at"], name="users_created_6541e9_idx"),
        ),
    ]
