diff --git a/apps/main/models/model_static_layer.py b/apps/main/models/model_static_layer.py index 2e6f469..5678905 100644 --- a/apps/main/models/model_static_layer.py +++ b/apps/main/models/model_static_layer.py @@ -1,31 +1,21 @@ +import uuid +import os from django.db import models +def get_upload_path(instance, filename): + ext = filename.split('.')[-1] + new_filename = f"{uuid.uuid4()}.{ext}" + return os.path.join('layers/', new_filename) + + def get_style_template() -> dict: return { - # Заливка - 'fill-color': 'rgba(255, 0, 0, 0.5)', - 'fill-opacity': 1, - - # Линия - 'stroke-color': 'blue', - 'stroke-width': 2, - 'stroke-opacity': 1, - - # # Круг (для точек. Потом на иконки заменить) - # 'circle-radius': 10, - # 'circle-fill-color': 'green', - # 'circle-stroke-color': 'black', - # 'circle-stroke-width': 1, - # - # # Текст - # 'text-value': 'Hello, OpenLayers!', - # 'text-font': '14px Calibri,sans-serif', - # 'text-color': 'white', - # 'text-offset-x': 0, - # 'text-offset-y': -20, - # 'text-align': 'center', - # 'text-baseline': 'middle', + "fill-color": "rgba(255, 0, 0, 0.5)", + "fill-opacity": 1, + "stroke-color": "blue", + "stroke-width": 2, + "stroke-opacity": 1, } @@ -37,7 +27,10 @@ class StaticLayer(models.Model): name = models.CharField(max_length=255, verbose_name="Название слоя") file = models.FileField( - upload_to="layers/", verbose_name="Файл слоя", null=True, blank=True + upload_to=get_upload_path, + verbose_name="Файл слоя", + null=True, + blank=True ) url = models.CharField( max_length=255, @@ -48,17 +41,13 @@ class StaticLayer(models.Model): layer_type = models.CharField( max_length=50, verbose_name="Тип слоя", default="Vector" ) - is_visible = models.BooleanField(default=True, - verbose_name="Видимость слоя") - layer_style = models.JSONField(blank=True, null=True, - default=get_style_template) + is_visible = models.BooleanField(default=True, verbose_name="Видимость слоя") order = models.IntegerField(default=0, verbose_name="Порядок отображения") def __str__(self): return self.name - class Meta: # отображение в админики + class Meta: verbose_name = "Статический слой" verbose_name_plural = "Статические слои" - indexes = [models.Index(fields=["name"]), - models.Index(fields=["is_visible"])] + indexes = [models.Index(fields=["name"]), models.Index(fields=["is_visible"])] \ No newline at end of file diff --git a/mfssogr/app_settings.py b/mfssogr/app_settings.py index 85539e0..c5a3088 100644 --- a/mfssogr/app_settings.py +++ b/mfssogr/app_settings.py @@ -42,7 +42,7 @@ INSTALLED_APPS = [ """Информация о приложении """ SITE_TITLE = "Многофункциональная система безопасности ОГР" SITE_TITLE_S = "МФСБ ОГР" -APP_VER = "1.0.13.0" +APP_VER = "1.0.13.1" APP_VEK = "2023 - 2025гг" APP_COPPIRIGHT = "Многофункциональная система безопасности ОГР"