Hotfix.
Добавлено создание имени файла на основе uuid
This commit is contained in:
parent
a2d219ab12
commit
c1d419fb77
@ -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"])]
|
||||
@ -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 = "Многофункциональная система безопасности ОГР"
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user