# Generated by Django 5.2.7 on 2025-12-15 13:21

import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ('mainapp', '0026_alter_userpermission_code'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='IssueType',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=255, verbose_name='Название')),
                ('category', models.CharField(choices=[('error', 'Ошибка'), ('malfunction', 'Неисправность')], default='error', max_length=20, verbose_name='Категория')),
                ('order', models.PositiveIntegerField(default=0, verbose_name='Порядок сортировки')),
                ('is_active', models.BooleanField(default=True, verbose_name='Активен')),
            ],
            options={
                'verbose_name': 'Тип ошибки/неисправности',
                'verbose_name_plural': 'Типы ошибок/неисправностей',
                'ordering': ['category', 'order', 'name'],
            },
        ),
        migrations.CreateModel(
            name='DailyReport',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('date', models.DateField(db_index=True, help_text='Дата отчёта', unique=True, verbose_name='Дата')),
                ('daily_work_hours', models.DecimalField(decimal_places=2, default=0, max_digits=5, verbose_name='Время работы за день (ч)')),
                ('weekly_work_hours', models.DecimalField(decimal_places=2, default=0, max_digits=6, verbose_name='Время работы за неделю (ч)')),
                ('explanation', models.TextField(blank=True, null=True, verbose_name='Пояснение')),
                ('comment', models.TextField(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='Обновлено')),
                ('created_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='daily_reports_created', to=settings.AUTH_USER_MODEL, verbose_name='Создал')),
            ],
            options={
                'verbose_name': 'Ежедневный отчёт',
                'verbose_name_plural': 'Ежедневные отчёты',
                'ordering': ['-date'],
            },
        ),
        migrations.CreateModel(
            name='DowntimePeriod',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('start_time', models.TimeField(verbose_name='Время начала')),
                ('end_time', models.TimeField(verbose_name='Время окончания')),
                ('reason', models.TextField(verbose_name='Причина простоя')),
                ('report', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='downtime_periods', to='mainapp.dailyreport', verbose_name='Отчёт')),
            ],
            options={
                'verbose_name': 'Период простоя',
                'verbose_name_plural': 'Периоды простоя',
                'ordering': ['start_time'],
            },
        ),
        migrations.CreateModel(
            name='IssueMark',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('is_present', models.BooleanField(default=False, verbose_name='Наличие')),
                ('report', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='issue_marks', to='mainapp.dailyreport', verbose_name='Отчёт')),
                ('issue_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='marks', to='mainapp.issuetype', verbose_name='Тип ошибки/неисправности')),
            ],
            options={
                'verbose_name': 'Отметка об ошибке',
                'verbose_name_plural': 'Отметки об ошибках',
                'ordering': ['issue_type__category', 'issue_type__order'],
                'unique_together': {('report', 'issue_type')},
            },
        ),
    ]
