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 @@
{{ com }}
+ {% for field, errors in form.errors.items %} + {% for error in errors %} +{{ error }}
+ {% endfor %} {% endfor %}{{ error }}
+ {% endfor %} +