diff --git a/.gitignore b/.gitignore index 2d1a7c8..bda3874 100644 --- a/.gitignore +++ b/.gitignore @@ -21,9 +21,10 @@ test* /.vscode .vscode .env -.env test_data .idea docker-compose.yml media log +png_and_tifs +dxfs \ No newline at end of file diff --git a/apps/gto/migrations/0015_alter_modeltypeicons_path.py b/apps/gto/migrations/0015_alter_modeltypeicons_path.py new file mode 100644 index 0000000..28ca400 --- /dev/null +++ b/apps/gto/migrations/0015_alter_modeltypeicons_path.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2.25 on 2025-05-15 09:22 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('gto', '0014_auto_20250121_1511'), + ] + + operations = [ + migrations.AlterField( + model_name='modeltypeicons', + name='path', + field=models.FileField(upload_to='map/gto'), + ), + ] diff --git a/apps/gto/migrations/0016_rename_path_modeltypeicons_icon.py b/apps/gto/migrations/0016_rename_path_modeltypeicons_icon.py new file mode 100644 index 0000000..4541649 --- /dev/null +++ b/apps/gto/migrations/0016_rename_path_modeltypeicons_icon.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2.25 on 2025-05-15 09:22 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('gto', '0015_alter_modeltypeicons_path'), + ] + + operations = [ + migrations.RenameField( + model_name='modeltypeicons', + old_name='path', + new_name='icon', + ), + ] diff --git a/apps/gto/migrations/0017_alter_modeltypeicons_icon.py b/apps/gto/migrations/0017_alter_modeltypeicons_icon.py new file mode 100644 index 0000000..443b5c6 --- /dev/null +++ b/apps/gto/migrations/0017_alter_modeltypeicons_icon.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2.25 on 2025-05-15 09:27 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('gto', '0016_rename_path_modeltypeicons_icon'), + ] + + operations = [ + migrations.AlterField( + model_name='modeltypeicons', + name='icon', + field=models.ImageField(upload_to='map/gto'), + ), + ] diff --git a/apps/gto/migrations/0018_auto_20250515_0933.py b/apps/gto/migrations/0018_auto_20250515_0933.py new file mode 100644 index 0000000..67adfe6 --- /dev/null +++ b/apps/gto/migrations/0018_auto_20250515_0933.py @@ -0,0 +1,22 @@ +# Generated by Django 3.2.25 on 2025-05-15 09:33 + +from django.db import migrations + + +def fix_icon_paths(apps, schema_editor): + ModelTypeIcons = apps.get_model("gto", "ModelTypeIcons") + for item in ModelTypeIcons.objects.all(): + if item.icon and 'media/' in item.icon.name: + item.icon.name = item.icon.name.replace('media/', '') + item.save() + + +class Migration(migrations.Migration): + + dependencies = [ + ("gto", "0017_alter_modeltypeicons_icon"), + ] + + operations = [ + migrations.RunPython(fix_icon_paths, reverse_code=migrations.RunPython.noop), + ] diff --git a/apps/gto/models/model_type_icons.py b/apps/gto/models/model_type_icons.py index 9418485..f1e6d21 100644 --- a/apps/gto/models/model_type_icons.py +++ b/apps/gto/models/model_type_icons.py @@ -3,11 +3,11 @@ from django.db import models class ModelTypeIcons(models.Model): model = models.CharField(max_length=128) - path = models.CharField(max_length=256) + icon = models.ImageField(upload_to='map/gto') # Изменили на FileField def __str__(self): return self.model - class Meta: # отображение в админики + class Meta: verbose_name = "Иконка оборудования" - verbose_name_plural = "Иконки оборудования" + verbose_name_plural = "Иконки оборудования" \ No newline at end of file diff --git a/apps/gto/templates/gto_main.html b/apps/gto/templates/gto_main.html index f92f63b..d7b85f5 100644 --- a/apps/gto/templates/gto_main.html +++ b/apps/gto/templates/gto_main.html @@ -133,9 +133,6 @@ Наименование Государственный номер Время координат - Широта - Долгота - Скорость @@ -178,15 +175,6 @@ {{ catalog.time }} - - {{ catalog.lat }} - - - {{ catalog.lon }} - - - {{ catalog.speed }} - {% endfor %} {% endif %} @@ -216,6 +204,7 @@ + {{ start_page_list_block|add:-1}}" aria-controls="mypaginator" data-dt-idx=" @@ -227,6 +216,7 @@ + {{ start_page_list_block|add:-1}}" style="padding: .3rem .5rem;">.. @@ -265,6 +255,7 @@ + {{ end_page_list_block|add:1}}" aria-controls="mypaginator" data-dt-idx=" @@ -276,6 +267,7 @@ + {{ end_page_list_block|add:1}}" style="padding: .3rem .5rem;">.. @@ -401,6 +393,34 @@ + - -{% endblock script_footer %} - diff --git a/apps/management/templates/icon_add.html b/apps/management/templates/icon_add.html index 5cb8c0f..fa90a48 100644 --- a/apps/management/templates/icon_add.html +++ b/apps/management/templates/icon_add.html @@ -48,39 +48,49 @@
- {% if error %} + {% if form.errors %}

Внимание !

- {% for com in error_comment %} -

{{ com }}

+ {% for field, errors in form.errors.items %} + {% for error in errors %} +

{{ error }}

+ {% endfor %} {% endfor %}
{% endif %}
- +
- + {{ form.model }}
- -
- -
-
- + +
+
+ {{ form.icon }} + + + {% if form.icon.errors %} +
+ {% for error in form.icon.errors %} +

{{ error }}

+ {% endfor %} +
+ {% endif %}
+
@@ -47,15 +51,21 @@
-
- - {{ form.name }} -
+
+ + {{ form.name }} +
+ +
+ + {{ form.icon }} +
+