updated
This commit is contained in:
19
rog/migrations/0002_alter_shapelayers_file.py
Normal file
19
rog/migrations/0002_alter_shapelayers_file.py
Normal file
@ -0,0 +1,19 @@
|
||||
# Generated by Django 3.2.9 on 2022-03-23 06:42
|
||||
|
||||
from django.db import migrations, models
|
||||
import rog.models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('rog', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='shapelayers',
|
||||
name='file',
|
||||
field=models.FileField(blank=True, upload_to=rog.models.get_file_path),
|
||||
),
|
||||
]
|
||||
@ -23,6 +23,7 @@ import csv
|
||||
import codecs
|
||||
import sys
|
||||
import time
|
||||
import uuid
|
||||
|
||||
env = environ.Env(DEBUG=(bool, False))
|
||||
environ.Env.read_env(env_file=".env")
|
||||
@ -311,9 +312,15 @@ def getMappingforModel(tbl, shp):
|
||||
return LayerMapping(Location_polygon, shp, location_polygon_mapping, transform=False)
|
||||
|
||||
|
||||
def get_file_path(instance, filename):
|
||||
ext = filename.split('.')[-1]
|
||||
filename = "%s.%s" % (uuid.uuid4(), ext)
|
||||
return os.path.join('uploads/logos', filename)
|
||||
|
||||
|
||||
class ShapeLayers(models.Model):
|
||||
name = models.CharField(_("Shape Layer"), max_length=255)
|
||||
file = models.FileField(upload_to='%y%m%d', blank=True)
|
||||
file = models.FileField(upload_to=get_file_path, blank=True)
|
||||
uploaded_date = models.DateField(auto_now_add=True)
|
||||
layerof = models.IntegerField(choices=LAYER_CHOICES, default=1)
|
||||
table_name = models.CharField(_("Table name"), max_length=255, blank=True)
|
||||
|
||||
Reference in New Issue
Block a user