diff --git a/dbapp/mainapp/migrations/0030_issuetype_location_place.py b/dbapp/mainapp/migrations/0030_issuetype_location_place.py new file mode 100644 index 0000000..83774f3 --- /dev/null +++ b/dbapp/mainapp/migrations/0030_issuetype_location_place.py @@ -0,0 +1,18 @@ +# Generated by Django 5.2.7 on 2025-12-16 08:09 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('mainapp', '0029_dailyreport_location_place'), + ] + + operations = [ + migrations.AddField( + model_name='issuetype', + name='location_place', + field=models.CharField(choices=[('kr', 'КР'), ('dv', 'ДВ')], default='kr', help_text='К какому комплексу принадлежит журнал', max_length=30, null=True, verbose_name='Комплекс'), + ), + ] diff --git a/dbapp/mainapp/migrations/0031_add_unique_date_location_constraint.py b/dbapp/mainapp/migrations/0031_add_unique_date_location_constraint.py new file mode 100644 index 0000000..093e409 --- /dev/null +++ b/dbapp/mainapp/migrations/0031_add_unique_date_location_constraint.py @@ -0,0 +1,24 @@ +# Generated by Django 5.2.7 on 2025-12-16 08:19 + +from django.conf import settings +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('mainapp', '0030_issuetype_location_place'), + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ] + + operations = [ + migrations.AlterField( + model_name='dailyreport', + name='date', + field=models.DateField(db_index=True, help_text='Дата отчёта', verbose_name='Дата'), + ), + migrations.AddConstraint( + model_name='dailyreport', + constraint=models.UniqueConstraint(fields=('date', 'location_place'), name='unique_daily_report_date_location'), + ), + ] diff --git a/dbapp/mainapp/models/errors_report.py b/dbapp/mainapp/models/errors_report.py index 8daef05..9ecab06 100644 --- a/dbapp/mainapp/models/errors_report.py +++ b/dbapp/mainapp/models/errors_report.py @@ -10,7 +10,18 @@ class IssueType(models.Model): ('error', 'Ошибка'), ('malfunction', 'Неисправность'), ] - + PLACES = [ + ("kr", "КР"), + ("dv", "ДВ") + ] + location_place = models.CharField( + max_length=30, + choices=PLACES, + null=True, + default="kr", + verbose_name="Комплекс", + help_text="К какому комплексу принадлежит журнал", + ) name = models.CharField(max_length=255, verbose_name="Название") category = models.CharField( max_length=20, @@ -35,7 +46,6 @@ class DailyReport(models.Model): ("dv", "ДВ") ] date = models.DateField( - unique=True, verbose_name="Дата", db_index=True, help_text="Дата отчёта" @@ -81,6 +91,12 @@ class DailyReport(models.Model): verbose_name = "Ежедневный отчёт" verbose_name_plural = "Ежедневные отчёты" ordering = ["-date"] + constraints = [ + models.UniqueConstraint( + fields=['date', 'location_place'], + name='unique_daily_report_date_location' + ) + ] class DowntimePeriod(models.Model): diff --git a/dbapp/mainapp/templates/mainapp/errors_report.html b/dbapp/mainapp/templates/mainapp/errors_report.html index f3c53cb..ed8b4c6 100644 --- a/dbapp/mainapp/templates/mainapp/errors_report.html +++ b/dbapp/mainapp/templates/mainapp/errors_report.html @@ -86,27 +86,37 @@

Журнал ошибок и неисправностей

-
+
+ +
+ + +
+ +
+
{% if user|has_perm:'errors_report_create' %} - {% endif %} -
@@ -139,22 +149,6 @@
- -
- -
- - -
- -
@@ -185,9 +176,6 @@ onclick="selectAllOptions('malfunctionFilter', false)">Снять
@@ -204,7 +192,12 @@
-
+ +
+

Выберите комплекс для отображения данных

+
+ +