added tem table for location data

This commit is contained in:
Mohamed Nouffer
2022-08-17 16:00:17 +05:30
parent 40ce2b1200
commit 8243e4a3fa
5 changed files with 242 additions and 30 deletions

View File

@ -235,6 +235,58 @@ class Location(models.Model):
return self.location_name
class templocation(models.Model):
location_id=models.IntegerField(_('Location id'), blank=True, null=True)
sub_loc_id=models.IntegerField(_('Sub location id'), blank=True, null=True)
cp=models.FloatField(_('Check Point'), blank=True, null=True)
location_name=models.CharField(_('Location Name'), max_length=2048, default="--- 場所をお願いします --")
category=models.CharField(_('Category'), max_length=2048, blank=True, null=True)
subcategory=models.CharField(_('Sub Category'), max_length=2048, blank=True, null=True)
zip=models.CharField(_('Zip code'), max_length=12, blank=True, null=True)
address = models.CharField(_('Address'), max_length=2048, blank=True, null=True)
prefecture = models.CharField(_('Prefecture'), max_length=2048, blank=True, null=True)
area= models.CharField(_('Area'), max_length=2048, blank=True, null=True)
city= models.CharField(_('City'), max_length=2048, blank=True, null=True)
latitude = models.FloatField('Latitude', blank=True, null=True)
longitude = models.FloatField('Latitude', blank=True, null=True)
photos=models.CharField(_('Photos'), max_length=2048, blank=True, null=True)
videos=models.CharField(_('Videos'), max_length=2048, blank=True, null=True)
webcontents=models.CharField(_('Web Content'), max_length=2048, blank=True, null=True)
status=models.CharField(_('Status'),max_length=2048, blank=True, null=True)
portal=models.CharField(_('Portal'), max_length=2048,blank=True, null=True)
group=models.CharField(_('Group'), max_length=2048,blank=True, null=True)
phone=models.CharField(_('Phone'), max_length=2048,blank=True, null=True)
fax=models.CharField(_('Fax'), max_length=2048, blank=True, null=True)
email=models.EmailField(_('Email'), max_length=2048,blank=True, null=True)
facility=models.CharField(_('Facility'), max_length=2048, blank=True, null=True)
remark=models.CharField(_('Remarks'), max_length=2048, blank=True, null=True)
tags=models.CharField(_('Tags'), max_length=2048, blank=True, null=True)
event_name = models.CharField(_('Event name'), max_length=2048, blank=True, null=True)
event_active = models.BooleanField(_("Is Event active"),default=True)
hidden_location = models.BooleanField(_("Is Hidden Location"),default=False)
auto_checkin = models.BooleanField(_("Is AutoCheckin"),default=False)
checkin_radius = models.FloatField(_("Checkin radious"), blank=True, null=True, default=15.0)
checkin_point = models.FloatField(_("Checkin Point"), blank=True, null=True, default=10)
buy_point = models.FloatField(_("buy Point"), blank=True, null=True, default=0)
evaluation_value = models.CharField(_('Evaluation value (評価)'),max_length=2048, blank=True, null=True)
shop_closed = models.BooleanField(_("Shop Closed (休業)"),default=False)
shop_shutdown = models.BooleanField(_("Shop Shutdown (閉業)"),default=False)
opening_hours_mon = models.CharField(_("Opening hours monday (月曜)"),max_length=512, blank=True, null=True)
opening_hours_tue = models.CharField(_("Opening hours tuesday (火曜)"), max_length=512,blank=True, null=True)
opening_hours_wed = models.CharField(_("Opening hours wednesday (水曜)"), max_length=512,blank=True, null=True)
opening_hours_thu = models.CharField(_("Opening hours thursday (木曜)"), max_length=512, blank=True, null=True)
opening_hours_fri = models.CharField(_("Opening hours frinday (金曜)"), max_length=512,blank=True, null=True)
opening_hours_sat = models.CharField(_("Opening hours saturday (土曜)"), max_length=512,blank=True, null=True)
opening_hours_sun = models.CharField(_("Opening hours sunday (日曜)"),max_length=512, blank=True, null=True)
parammeters=models.CharField(_('Parameters'), max_length=2048, blank=True, null=True)
created_at=models.DateTimeField(auto_now_add=True)
last_updated_user=models.ForeignKey(CustomUser, related_name="temp_location_updated_user", on_delete=models.DO_NOTHING,blank=True, null=True)
last_updated_at=models.DateTimeField(auto_now=True)
geom=models.MultiPointField(srid=4326)
def __str__(self):
return self.location_name
class Location_line(models.Model):
location_id=models.IntegerField(_('Location id'), blank=True, null=True)
location_name=models.CharField(_('Location Name'), max_length=255)
@ -428,15 +480,15 @@ class TestModel(models.Model):
def getTableForModel(tbl):
if tbl == 1:
return Location.objects.model._meta.db_table;
return templocation.objects.model._meta.db_table;
elif tbl == 2:
return Location_line.objects.model._meta.db_table;
else:
return Location_polygon.objects.model._meta.db_table;
def getMappingforModel(tbl, shp):
def getTempMappingforModel(tbl, shp):
if tbl == 1:
return LayerMapping(Location, shp, location_mapping, transform=False)
return LayerMapping(templocation, shp, location_mapping, transform=False)
elif tbl == 2:
return LayerMapping(Location_line, shp, location_line_mapping, transform=False)
else:
@ -488,7 +540,7 @@ def remove_bom_inplace(path):
@receiver(pre_save, sender=Location)
def location_presave(sender, instance, *args, **kwargs):
#print("------############------------", instance.location_id)
Location.objects.filter(location_id = instance.location_id).delete()
templocation.objects.filter(location_id = instance.location_id).delete()
@receiver(pre_save, sender=Location_line)
@ -518,7 +570,7 @@ def deleteShapelocation(sender,instance,*args,**kwargs):
print("------- name----")
print(locids)
print("------- name----")
Location.objects.filter(location_id__in=locids).delete()
templocation.objects.all().delete()
ShapeFileLocations.objects.filter(shapefile=instance.name).delete()
@ -548,7 +600,7 @@ def publish_data(sender, instance, created, **kwargs):
if epsg is None:
epsg=4326
lm2 = getMappingforModel(instance.layerof, shp)
lm2 = getTempMappingforModel(instance.layerof, shp)
print("### shape file is ###")
lm2.save(strict=True, verbose=True)