initial update by Akira -- need to update email templates
This commit is contained in:
133
rog/models.py
133
rog/models.py
@ -34,6 +34,9 @@ import codecs
|
|||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
import uuid
|
import uuid
|
||||||
|
import logging
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
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")
|
||||||
@ -830,7 +833,7 @@ class ShapeFileLocations(models.Model):
|
|||||||
|
|
||||||
@receiver(pre_save, sender=Location)
|
@receiver(pre_save, sender=Location)
|
||||||
def location_presave(sender, instance, *args, **kwargs):
|
def location_presave(sender, instance, *args, **kwargs):
|
||||||
#print("------############------------", instance.location_id)
|
print("------############------------", instance.location_id)
|
||||||
templocation.objects.filter(location_id = instance.location_id).delete()
|
templocation.objects.filter(location_id = instance.location_id).delete()
|
||||||
|
|
||||||
|
|
||||||
@ -868,6 +871,8 @@ def deleteShapelocation(sender,instance,*args,**kwargs):
|
|||||||
|
|
||||||
@receiver(post_save, sender=ShapeLayers)
|
@receiver(post_save, sender=ShapeLayers)
|
||||||
def publish_data(sender, instance, created, **kwargs):
|
def publish_data(sender, instance, created, **kwargs):
|
||||||
|
logger.info(f"Processing ShapeLayer: {instance.name}")
|
||||||
|
|
||||||
file = instance.file.path
|
file = instance.file.path
|
||||||
file_format = os.path.basename(file).split('.')[-1]
|
file_format = os.path.basename(file).split('.')[-1]
|
||||||
file_name = os.path.basename(file).split('.')[0]
|
file_name = os.path.basename(file).split('.')[0]
|
||||||
@ -881,25 +886,37 @@ def publish_data(sender, instance, created, **kwargs):
|
|||||||
os.remove(file)
|
os.remove(file)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
logger.debug("Attempting to read shape file")
|
||||||
|
|
||||||
# print("before reading the file")
|
# print("before reading the file")
|
||||||
shp = glob.glob(r'{}/**/*.shp'.format(file_path), recursive=True)[0]
|
shp = glob.glob(r'{}/**/*.shp'.format(file_path), recursive=True)[0]
|
||||||
|
|
||||||
|
logger.info(f"Shape file read: {shp}")
|
||||||
|
|
||||||
# print("this is the read file",shp)
|
# print("this is the read file",shp)
|
||||||
gdf = gpd.read_file(shp)
|
gdf = gpd.read_file(shp)
|
||||||
crs_name = str(gdf.crs.srs)
|
crs_name = str(gdf.crs.srs)
|
||||||
|
logger.debug(f"CRS name: {crs_name}")
|
||||||
|
|
||||||
# print(crs_name, 'crs - name')
|
# print(crs_name, 'crs - name')
|
||||||
epsg = int(crs_name.replace('epsg:',''))
|
epsg = int(crs_name.replace('epsg:',''))
|
||||||
if epsg is None:
|
if epsg is None:
|
||||||
epsg=4326
|
epsg=4326
|
||||||
|
|
||||||
lm2 = getTempMappingforModel(instance.layerof, shp)
|
lm2 = getTempMappingforModel(instance.layerof, shp)
|
||||||
|
logger.info("Saving to temporary table")
|
||||||
|
|
||||||
# print("### shape file is ###")
|
# print("### shape file is ###")
|
||||||
lm2.save(strict=True, verbose=True)
|
lm2.save(strict=True, verbose=True)
|
||||||
|
logger.info("Save to temporary table completed")
|
||||||
|
|
||||||
os.remove(shp)
|
os.remove(shp)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print('######## shape file##########',e)
|
print('######## shape file##########',e)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
logger.debug("Attempting to read CSV file")
|
||||||
|
|
||||||
csv_f = glob.glob(r'{}/**/*.csv'.format(file_path), recursive=True)[0]
|
csv_f = glob.glob(r'{}/**/*.csv'.format(file_path), recursive=True)[0]
|
||||||
|
|
||||||
remove_bom_inplace(csv_f)
|
remove_bom_inplace(csv_f)
|
||||||
@ -907,10 +924,13 @@ def publish_data(sender, instance, created, **kwargs):
|
|||||||
mdl = apps.get_model(app_label="rog", model_name=LAYER_CHOICES[instance.layerof -1][1])
|
mdl = apps.get_model(app_label="rog", model_name=LAYER_CHOICES[instance.layerof -1][1])
|
||||||
# print(mdl)
|
# print(mdl)
|
||||||
# print(f"#### instance.layerof - {instance.layerof}")
|
# print(f"#### instance.layerof - {instance.layerof}")
|
||||||
|
logger.debug(f"Model for layer: {mdl}")
|
||||||
|
|
||||||
with open(csv_f, mode="r", encoding="utf-8") as txt_file:
|
with open(csv_f, mode="r", encoding="utf-8") as txt_file:
|
||||||
#heading = next(txt_file)
|
#heading = next(txt_file)
|
||||||
reader = csv.reader(txt_file, delimiter=",")
|
reader = csv.reader(txt_file, delimiter=",")
|
||||||
for fields in reader:
|
for fields in reader:
|
||||||
|
logger.debug(f"Processing row: {fields[0]}")
|
||||||
print("@@@@@@@@@@@@")
|
print("@@@@@@@@@@@@")
|
||||||
print(fields[0])
|
print(fields[0])
|
||||||
print("@@@@@@@@@@@@")
|
print("@@@@@@@@@@@@")
|
||||||
@ -925,26 +945,35 @@ def publish_data(sender, instance, created, **kwargs):
|
|||||||
with open(csv_f, mode="r", encoding="utf-8") as txt_file:
|
with open(csv_f, mode="r", encoding="utf-8") as txt_file:
|
||||||
reader_2 = csv.reader(txt_file, delimiter=",")
|
reader_2 = csv.reader(txt_file, delimiter=",")
|
||||||
for fields in reader_2:
|
for fields in reader_2:
|
||||||
|
logger.debug(f"Inserting ShapeLayerLocation: {fields[0]}")
|
||||||
print("@@@@@@@@@@@@")
|
print("@@@@@@@@@@@@")
|
||||||
print(fields[0])
|
print(fields[0])
|
||||||
print("@@@@@@@@@@@@")
|
print("@@@@@@@@@@@@")
|
||||||
if instance.layerof == 1:
|
if instance.layerof == 1:
|
||||||
insertShapeLayerLocation(instance.name, fields)
|
insertShapeLayerLocation(instance.name, fields)
|
||||||
|
|
||||||
|
logger.info("CSV processing completed")
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print('######## csv file ##########',e)
|
print('######## csv file ##########',e)
|
||||||
|
|
||||||
|
|
||||||
def insertShapeLayerLocation(name, fields):
|
def insertShapeLayerLocation(name, fields):
|
||||||
sll = UserUploadUser(userfile=name, email=fields[0])
|
logger.info(f"Attempting to insert ShapeFileLocations for file: {name}, location_id: {fields[0]}")
|
||||||
sll.save();
|
try:
|
||||||
|
sll = UserUploadUser(userfile=name, email=fields[0])
|
||||||
|
sll.save();
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"Error inserting ShapeFileLocations: {e}", exc_info=True)
|
||||||
|
|
||||||
|
|
||||||
def insertUserUploadUser(name, fields):
|
def insertUserUploadUser(name, fields):
|
||||||
with transaction.atomic():
|
try:
|
||||||
sll = UserUploadUser(userfile=name, email=fields[0])
|
with transaction.atomic():
|
||||||
sll.save()
|
sll = UserUploadUser(userfile=name, email=fields[0])
|
||||||
|
sll.save()
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"Error updating TempLocation: {e}", exc_info=True)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -953,48 +982,54 @@ def updateLocation(mdl, fields):
|
|||||||
print(mdl.objects.filter(location_id = int(fields[0])))
|
print(mdl.objects.filter(location_id = int(fields[0])))
|
||||||
print(f"--- ${fields} ----")
|
print(f"--- ${fields} ----")
|
||||||
|
|
||||||
with transaction.atomic():
|
try:
|
||||||
mdl.objects.filter(location_id = int(fields[0])).update(
|
with transaction.atomic():
|
||||||
sub_loc_id = fields[1] if len(fields[1]) > 0 else '',
|
updated = mdl.objects.filter(location_id = int(fields[0])).update(
|
||||||
cp = fields[2] if len(fields[2]) > 0 else 0,
|
sub_loc_id = fields[1] if len(fields[1]) > 0 else '',
|
||||||
location_name = fields[3] if len(fields[3]) > 0 else '',
|
cp = fields[2] if len(fields[2]) > 0 else 0,
|
||||||
category = fields[4] if len(fields[4]) > 0 else '',
|
location_name = fields[3] if len(fields[3]) > 0 else '',
|
||||||
subcategory = fields[5] if len(fields[5]) > 0 else '',
|
category = fields[4] if len(fields[4]) > 0 else '',
|
||||||
zip = fields[6] if len(fields[6]) > 0 else '',
|
subcategory = fields[5] if len(fields[5]) > 0 else '',
|
||||||
address = fields[7] if len(fields[7]) > 0 else '',
|
zip = fields[6] if len(fields[6]) > 0 else '',
|
||||||
prefecture = fields[8] if len(fields[8]) > 0 else '',
|
address = fields[7] if len(fields[7]) > 0 else '',
|
||||||
area = fields[9] if len(fields[9]) > 0 else '',
|
prefecture = fields[8] if len(fields[8]) > 0 else '',
|
||||||
city = fields[10] if len(fields[10]) > 0 else '',
|
area = fields[9] if len(fields[9]) > 0 else '',
|
||||||
latitude = fields[11] if len(fields[11]) > 0 else '',
|
city = fields[10] if len(fields[10]) > 0 else '',
|
||||||
longitude = fields[12] if len(fields[12]) > 0 else '',
|
latitude = fields[11] if len(fields[11]) > 0 else '',
|
||||||
photos = fields[13] if len(fields[13]) > 0 else '',
|
longitude = fields[12] if len(fields[12]) > 0 else '',
|
||||||
videos = fields[14] if len(fields[14]) > 0 else '',
|
photos = fields[13] if len(fields[13]) > 0 else '',
|
||||||
webcontents = fields[15] if len(fields[15]) > 0 else '',
|
videos = fields[14] if len(fields[14]) > 0 else '',
|
||||||
status = fields[16] if len(fields[16]) > 0 else '',
|
webcontents = fields[15] if len(fields[15]) > 0 else '',
|
||||||
portal = fields[17] if len(fields[17]) > 0 else '',
|
status = fields[16] if len(fields[16]) > 0 else '',
|
||||||
group = fields[18] if len(fields[18]) > 0 else '',
|
portal = fields[17] if len(fields[17]) > 0 else '',
|
||||||
phone = fields[19] if len(fields[19]) > 0 else '',
|
group = fields[18] if len(fields[18]) > 0 else '',
|
||||||
fax = fields[20] if len(fields[20]) > 0 else '',
|
phone = fields[19] if len(fields[19]) > 0 else '',
|
||||||
email = fields[21] if len(fields[21]) > 0 else '',
|
fax = fields[20] if len(fields[20]) > 0 else '',
|
||||||
facility = fields[22] if len(fields[22]) > 0 else '',
|
email = fields[21] if len(fields[21]) > 0 else '',
|
||||||
remark = fields[23] if len(fields[23]) > 0 else '',
|
facility = fields[22] if len(fields[22]) > 0 else '',
|
||||||
tags = fields[24] if len(fields[24]) > 0 else '',
|
remark = fields[23] if len(fields[23]) > 0 else '',
|
||||||
hidden_location = fields[25] if len(fields[25]) > 0 else False,
|
tags = fields[24] if len(fields[24]) > 0 else '',
|
||||||
auto_checkin = fields[26] if len(fields[26]) > 0 else False,
|
hidden_location = fields[25] if len(fields[25]) > 0 else False,
|
||||||
checkin_radius = fields[27] if len(fields[27]) > 0 else 15,
|
auto_checkin = fields[26] if len(fields[26]) > 0 else False,
|
||||||
checkin_point = fields[28] if len(fields[28]) > 0 else 10,
|
checkin_radius = fields[27] if len(fields[27]) > 0 else 15,
|
||||||
buy_point = fields[29] if len(fields[29]) > 0 else 0,
|
checkin_point = fields[28] if len(fields[28]) > 0 else 10,
|
||||||
evaluation_value = fields[30] if len(fields[30]) > 0 else '',
|
buy_point = fields[29] if len(fields[29]) > 0 else 0,
|
||||||
shop_closed = fields[31] if len(fields[31]) > 0 else False,
|
evaluation_value = fields[30] if len(fields[30]) > 0 else '',
|
||||||
shop_shutdown = fields[32] if len(fields[32]) > 0 else False,
|
shop_closed = fields[31] if len(fields[31]) > 0 else False,
|
||||||
opening_hours_mon = fields[33] if len(fields[33]) > 0 else '',
|
shop_shutdown = fields[32] if len(fields[32]) > 0 else False,
|
||||||
opening_hours_tue = fields[34] if len(fields[34]) > 0 else '',
|
opening_hours_mon = fields[33] if len(fields[33]) > 0 else '',
|
||||||
opening_hours_wed = fields[35] if len(fields[35]) > 0 else '',
|
opening_hours_tue = fields[34] if len(fields[34]) > 0 else '',
|
||||||
opening_hours_thu = fields[36] if len(fields[36]) > 0 else '',
|
opening_hours_wed = fields[35] if len(fields[35]) > 0 else '',
|
||||||
opening_hours_fri = fields[37] if len(fields[37]) > 0 else '',
|
opening_hours_thu = fields[36] if len(fields[36]) > 0 else '',
|
||||||
opening_hours_sat = fields[38] if len(fields[38]) > 0 else '',
|
opening_hours_fri = fields[37] if len(fields[37]) > 0 else '',
|
||||||
opening_hours_sun = fields[39] if len(fields[39]) > 0 else ''
|
opening_hours_sat = fields[38] if len(fields[38]) > 0 else '',
|
||||||
)
|
opening_hours_sun = fields[39] if len(fields[39]) > 0 else ''
|
||||||
|
)
|
||||||
|
logger.info(f"TempLocation updated successfully. Rows affected: {updated}")
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"Error updating TempLocation: {e}", exc_info=True)
|
||||||
|
|
||||||
|
|
||||||
def updateLineTable(mdl, fields):
|
def updateLineTable(mdl, fields):
|
||||||
print(f"Updating {fields[0]} - {fields[1]}")
|
print(f"Updating {fields[0]} - {fields[1]}")
|
||||||
@ -1077,6 +1112,8 @@ def deleteUserUploadUser(sender,instance,*args,**kwargs):
|
|||||||
|
|
||||||
@receiver(post_save, sender=UserUpload)
|
@receiver(post_save, sender=UserUpload)
|
||||||
def publish_data(sender, instance, created, **kwargs):
|
def publish_data(sender, instance, created, **kwargs):
|
||||||
|
logger.info(f"Processing ShapeLayer: {instance.name}")
|
||||||
|
|
||||||
file = instance.file.path
|
file = instance.file.path
|
||||||
#os.remove(file)
|
#os.remove(file)
|
||||||
|
|
||||||
|
|||||||
6
rog/templates/email/entry_notification_email.txt
Normal file
6
rog/templates/email/entry_notification_email.txt
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
こちらは岐阜aiネットワークです。
|
||||||
|
あなた様の岐阜ロゲエントリーが決定いたしましたことをお伝えいたします。
|
||||||
|
残暑厳しい中でのロゲイニングですが、水分補給をしっかり行ってご参加いただければ幸いです。
|
||||||
|
それでは、今後とも岐阜ロゲをよろしくお願いいたします。
|
||||||
|
|
||||||
|
本メールは送信専用のメールアドレスで送信しております。 本メールに返信いただいてもご回答いたしかねますので、あらかじめご了承ください(ご質問等はinfo@gifuai.netまでお願いいたします)。もしこのメールに心当たりがない場合は破棄願います。
|
||||||
@ -14,3 +14,12 @@
|
|||||||
よろしくお願いいたします。
|
よろしくお願いいたします。
|
||||||
|
|
||||||
{service_name} チーム
|
{service_name} チーム
|
||||||
|
|
||||||
|
|
||||||
|
こちらは岐阜aiネットワークです。
|
||||||
|
このメールは{{招待者}}さんから、あなたへの、岐阜ロゲチームへの招待メールです。こちらをタップしていただければ{{招待者}}さんのチームの正式メンバーとして登録されます。https://xxx.xxxx.xxxxx
|
||||||
|
それでは、今後とも岐阜ロゲをよろしくお願いいたします。
|
||||||
|
|
||||||
|
本メールは送信専用のメールアドレスで送信しております。 本メールに返信いただいてもご回答いたしかねますので、あらかじめご了承ください(ご質問等はinfo@gifuai.netまでお願いいたします)。もしこのメールに心当たりがない場合は破棄願います。
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -14,3 +14,12 @@
|
|||||||
よろしくお願いいたします。
|
よろしくお願いいたします。
|
||||||
|
|
||||||
{service_name} チーム
|
{service_name} チーム
|
||||||
|
|
||||||
|
|
||||||
|
こちらは岐阜aiネットワークです。
|
||||||
|
このメールは{{招待者}}さんから、あなたへの、岐阜ロゲチームへの招待メールです。現在あなたは仮登録の状態ですので、まずは次のリンクをタップしてメンバーとして登録していただき、その後でこちらから岐阜ロゲアプリのダウンロードとインストール及び招待時のユーザー名でのログインをお願いします。個人情報を入力していただくことでチームに正式登録されます。https://xxx.xxxx.xxxxx
|
||||||
|
それでは、今後とも岐阜ロゲをよろしくお願いいたします。
|
||||||
|
|
||||||
|
本メールは送信専用のメールアドレスで送信しております。 本メールに返信いただいてもご回答いたしかねますので、あらかじめご了承ください(ご質問等はinfo@gifuai.netまでお願いいたします)。もしこのメールに心当たりがない場合は破棄願います。
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -14,3 +14,16 @@
|
|||||||
よろしくお願いいたします。
|
よろしくお願いいたします。
|
||||||
|
|
||||||
{service_name} チーム
|
{service_name} チーム
|
||||||
|
|
||||||
|
|
||||||
|
件名:岐阜ロゲのアクティベーション
|
||||||
|
{name} 様
|
||||||
|
|
||||||
|
こちらは岐阜aiネットワークです。
|
||||||
|
この度は岐阜ロゲアプリのダウンロードおよびユーザー登録、誠にありがとうございました。あなた様の登録で間違いがなければ、こちらをタップしログインページにお進みください。https://xxx.xxxx.xxxxx
|
||||||
|
それでは、今後とも岐阜ロゲをよろしくお願いいたします。
|
||||||
|
|
||||||
|
本メールは送信専用のメールアドレスで送信しております。 本メールに返信いただいてもご回答いたしかねますので、あらかじめご了承ください(ご質問等はinfo@gifuai.netまでお願いいたします)。もしこのメールに心当たりがない場合は破棄願います。
|
||||||
|
|
||||||
|
|
||||||
|
{service_name} チーム
|
||||||
|
|||||||
Reference in New Issue
Block a user