From b6359d08cddf3fe18c057ddfefde8d0d95963c99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D0=BE=D1=88=D0=BA=D0=B8=D0=BD=20=D0=A1=D0=B5=D1=80?= =?UTF-8?q?=D0=B3=D0=B5=D0=B9?= Date: Tue, 16 Dec 2025 11:44:56 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D1=84=D0=B8=D0=BA=D1=81=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=B6=D1=83=D1=80=D0=BD=D0=B0=D0=BB=20=D0=BE=D1=88?= =?UTF-8?q?=D0=B8=D0=B1=D0=BE=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../0030_issuetype_location_place.py | 18 ++ ...031_add_unique_date_location_constraint.py | 24 ++ dbapp/mainapp/models/errors_report.py | 20 +- .../templates/mainapp/errors_report.html | 246 ++++++++++++------ dbapp/mainapp/views/errors_report.py | 44 +++- 5 files changed, 258 insertions(+), 94 deletions(-) create mode 100644 dbapp/mainapp/migrations/0030_issuetype_location_place.py create mode 100644 dbapp/mainapp/migrations/0031_add_unique_date_location_constraint.py 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 @@
-
+ +
+

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

+
+ +