update for city admin

This commit is contained in:
Mohamed Nouffer
2022-09-27 17:52:14 +05:30
parent f17be54d81
commit 50fa4ac71b
4 changed files with 19 additions and 12 deletions

View File

@ -616,18 +616,18 @@ def publish_data(sender, instance, created, **kwargs):
os.remove(file)
try:
print("before reading the file")
# print("before reading the file")
shp = glob.glob(r'{}/**/*.shp'.format(file_path), recursive=True)[0]
print("this is the read file",shp)
# print("this is the read file",shp)
gdf = gpd.read_file(shp)
crs_name = str(gdf.crs.srs)
print(crs_name, 'crs - name')
# print(crs_name, 'crs - name')
epsg = int(crs_name.replace('epsg:',''))
if epsg is None:
epsg=4326
lm2 = getTempMappingforModel(instance.layerof, shp)
print("### shape file is ###")
# print("### shape file is ###")
lm2.save(strict=True, verbose=True)
os.remove(shp)
@ -640,8 +640,8 @@ def publish_data(sender, instance, created, **kwargs):
remove_bom_inplace(csv_f)
mdl = apps.get_model(app_label="rog", model_name=LAYER_CHOICES[instance.layerof -1][1])
print(mdl)
print(f"#### instance.layerof - {instance.layerof}")
# print(mdl)
# print(f"#### instance.layerof - {instance.layerof}")
with open(csv_f, mode="r", encoding="utf-8") as txt_file:
#heading = next(txt_file)
reader = csv.reader(txt_file, delimiter=",")
@ -686,11 +686,11 @@ def insertUserUploadUser(name, fields):
def updateLocation(mdl, fields):
print(f"Updating {fields[0]} - {fields[1]}")
print(mdl.objects.filter(location_id = int(fields[0])))
print("-------")
print(f"--- ${fields} ----")
with transaction.atomic():
mdl.objects.filter(location_id = int(fields[0])).update(
sub_loc_id = fields[1] if len(fields[1]) > 0 else 0,
sub_loc_id = fields[1] if len(fields[1]) > 0 else '',
cp = fields[2] if len(fields[2]) > 0 else 0,
location_name = fields[3] if len(fields[3]) > 0 else '',
category = fields[4] if len(fields[4]) > 0 else '',