This commit is contained in:
Mohamed Nouffer
2022-03-23 12:13:30 +05:30
parent c28fdbe2b2
commit dc99a6bac3
2 changed files with 27 additions and 1 deletions

View 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),
),
]

View File

@ -23,6 +23,7 @@ import csv
import codecs import codecs
import sys import sys
import time import time
import uuid
env = environ.Env(DEBUG=(bool, False)) env = environ.Env(DEBUG=(bool, False))
environ.Env.read_env(env_file=".env") 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) 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): class ShapeLayers(models.Model):
name = models.CharField(_("Shape Layer"), max_length=255) 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) uploaded_date = models.DateField(auto_now_add=True)
layerof = models.IntegerField(choices=LAYER_CHOICES, default=1) layerof = models.IntegerField(choices=LAYER_CHOICES, default=1)
table_name = models.CharField(_("Table name"), max_length=255, blank=True) table_name = models.CharField(_("Table name"), max_length=255, blank=True)