From 8e0d32c307b578de525c93017e4acf2f73bb0eba 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: Thu, 13 Nov 2025 17:54:06 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=BB=D1=83=D1=87=D1=88=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=B8=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dbapp/mainapp/admin.py | 1 - dbapp/mainapp/forms.py | 13 +- .../0004_change_geo_mirrors_to_satellites.py | 18 ++ dbapp/mainapp/models.py | 4 +- .../_column_visibility_dropdown.html | 1 + .../components/_selected_items_offcanvas.html | 1 + .../templates/mainapp/objitem_detail.html | 35 ++- .../templates/mainapp/objitem_form.html | 7 +- .../templates/mainapp/objitem_list.html | 24 +- dbapp/mainapp/tests.py | 251 +++++++++++++++++- dbapp/mainapp/utils.py | 180 ++++++++++--- dbapp/mainapp/views/objitem.py | 9 + 12 files changed, 476 insertions(+), 68 deletions(-) create mode 100644 dbapp/mainapp/migrations/0004_change_geo_mirrors_to_satellites.py diff --git a/dbapp/mainapp/admin.py b/dbapp/mainapp/admin.py index a8a852b..c78fca1 100644 --- a/dbapp/mainapp/admin.py +++ b/dbapp/mainapp/admin.py @@ -482,7 +482,6 @@ class SigmaParameterAdmin(ImportExportActionModelAdmin, BaseAdmin): "modulation__name", "standard__name", ) - autocomplete_fields = ("mark",) ordering = ("-frequency",) diff --git a/dbapp/mainapp/forms.py b/dbapp/mainapp/forms.py index c80bb4a..2af93da 100644 --- a/dbapp/mainapp/forms.py +++ b/dbapp/mainapp/forms.py @@ -3,6 +3,7 @@ from django import forms # Local imports from .models import Geo, Modulation, ObjItem, Parameter, Polarization, Satellite, Standard +from .widgets import TagSelectWidget class UploadFileForm(forms.Form): file = forms.FileField( @@ -294,11 +295,21 @@ class ParameterForm(forms.ModelForm): class GeoForm(forms.ModelForm): class Meta: model = Geo - fields = ['location', 'comment', 'is_average'] + fields = ['location', 'comment', 'is_average', 'mirrors'] widgets = { 'location': forms.TextInput(attrs={'class': 'form-control'}), 'comment': forms.TextInput(attrs={'class': 'form-control'}), 'is_average': forms.CheckboxInput(attrs={'class': 'form-check-input'}), + 'mirrors': TagSelectWidget(attrs={'id': 'id_geo-mirrors'}), + } + labels = { + 'location': 'Местоположение', + 'comment': 'Комментарий', + 'is_average': 'Усреднённое', + 'mirrors': 'Спутники-зеркала, использованные для приёма', + } + help_texts = { + 'mirrors': 'Начните вводить название спутника для поиска', } class ObjItemForm(forms.ModelForm): diff --git a/dbapp/mainapp/migrations/0004_change_geo_mirrors_to_satellites.py b/dbapp/mainapp/migrations/0004_change_geo_mirrors_to_satellites.py new file mode 100644 index 0000000..8f3afae --- /dev/null +++ b/dbapp/mainapp/migrations/0004_change_geo_mirrors_to_satellites.py @@ -0,0 +1,18 @@ +# Generated by Django 5.2.7 on 2025-11-13 14:05 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('mainapp', '0003_source_coords_average_alter_objitem_source_and_more'), + ] + + operations = [ + migrations.AlterField( + model_name='geo', + name='mirrors', + field=models.ManyToManyField(blank=True, help_text='Спутники-зеркала, использованные для приема', related_name='geo_mirrors', to='mainapp.satellite', verbose_name='Зеркала'), + ), + ] diff --git a/dbapp/mainapp/models.py b/dbapp/mainapp/models.py index f254b2e..d583ebb 100644 --- a/dbapp/mainapp/models.py +++ b/dbapp/mainapp/models.py @@ -873,11 +873,11 @@ class Geo(models.Model): # Связи mirrors = models.ManyToManyField( - Mirror, + Satellite, related_name="geo_mirrors", verbose_name="Зеркала", blank=True, - help_text="Зеркала антенн, использованные для приема", + help_text="Спутники-зеркала, использованные для приема", ) objitem = models.OneToOneField( ObjItem, diff --git a/dbapp/mainapp/templates/mainapp/components/_column_visibility_dropdown.html b/dbapp/mainapp/templates/mainapp/components/_column_visibility_dropdown.html index 4355541..adfefa7 100644 --- a/dbapp/mainapp/templates/mainapp/components/_column_visibility_dropdown.html +++ b/dbapp/mainapp/templates/mainapp/components/_column_visibility_dropdown.html @@ -40,5 +40,6 @@ {% include 'mainapp/components/_column_toggle_item.html' with column_index=18 column_label="Стандарт" checked=False %} {% include 'mainapp/components/_column_toggle_item.html' with column_index=19 column_label="Тип источника" checked=True %} {% include 'mainapp/components/_column_toggle_item.html' with column_index=20 column_label="Sigma" checked=True %} + {% include 'mainapp/components/_column_toggle_item.html' with column_index=21 column_label="Зеркала" checked=True %} \ No newline at end of file diff --git a/dbapp/mainapp/templates/mainapp/components/_selected_items_offcanvas.html b/dbapp/mainapp/templates/mainapp/components/_selected_items_offcanvas.html index b940c8d..2f580cb 100644 --- a/dbapp/mainapp/templates/mainapp/components/_selected_items_offcanvas.html +++ b/dbapp/mainapp/templates/mainapp/components/_selected_items_offcanvas.html @@ -47,6 +47,7 @@ Кем(обн) Создано Кем(созд) + Зеркала diff --git a/dbapp/mainapp/templates/mainapp/objitem_detail.html b/dbapp/mainapp/templates/mainapp/objitem_detail.html index 926a26f..1ace95a 100644 --- a/dbapp/mainapp/templates/mainapp/objitem_detail.html +++ b/dbapp/mainapp/templates/mainapp/objitem_detail.html @@ -243,19 +243,36 @@ {% if object.geo_obj.timestamp %}{{ object.geo_obj.timestamp|date:"d.m.Y H:i" }}{% else %}-{% endif %} -
-
- -
- {% if object.geo_obj.is_average %}Да{% else %}Нет{% endif %} -
+
+
+
+ +
+ {% if object.geo_obj.is_average %}Да{% else %}Нет{% endif %}
- {% else %} -

Нет данных о геолокации

- {% endif %}
+ +
+
+
+ +
+ {% if object.geo_obj.mirrors.all %} + {% for mirror in object.geo_obj.mirrors.all %} + {{ mirror.name }}{% if not forloop.last %}, {% endif %} + {% endfor %} + {% else %} + - + {% endif %} +
+
+
+
+ {% else %} +

Нет данных о геолокации

+ {% endif %}
diff --git a/dbapp/mainapp/templates/mainapp/objitem_form.html b/dbapp/mainapp/templates/mainapp/objitem_form.html index c406150..a7ce7d7 100644 --- a/dbapp/mainapp/templates/mainapp/objitem_form.html +++ b/dbapp/mainapp/templates/mainapp/objitem_form.html @@ -235,6 +235,12 @@ {% include 'mainapp/components/_form_field.html' with field=geo_form.is_average %}
+ +
+
+ {% include 'mainapp/components/_form_field.html' with field=geo_form.mirrors %} +
+
@@ -247,7 +253,6 @@ {% leaflet_css %} -