initial update by Akira -- need to update email templates

This commit is contained in:
2024-07-29 03:26:33 +00:00
parent 44ad30093c
commit 26e8e68dbd
5 changed files with 124 additions and 50 deletions

View File

@ -34,6 +34,9 @@ import codecs
import sys
import time
import uuid
import logging
logger = logging.getLogger(__name__)
env = environ.Env(DEBUG=(bool, False))
environ.Env.read_env(env_file=".env")
@ -830,7 +833,7 @@ class ShapeFileLocations(models.Model):
@receiver(pre_save, sender=Location)
def location_presave(sender, instance, *args, **kwargs):
#print("------############------------", instance.location_id)
print("------############------------", instance.location_id)
templocation.objects.filter(location_id = instance.location_id).delete()
@ -868,6 +871,8 @@ def deleteShapelocation(sender,instance,*args,**kwargs):
@receiver(post_save, sender=ShapeLayers)
def publish_data(sender, instance, created, **kwargs):
logger.info(f"Processing ShapeLayer: {instance.name}")
file = instance.file.path
file_format = os.path.basename(file).split('.')[-1]
file_name = os.path.basename(file).split('.')[0]
@ -881,25 +886,37 @@ def publish_data(sender, instance, created, **kwargs):
os.remove(file)
try:
logger.debug("Attempting to read shape file")
# print("before reading the file")
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)
gdf = gpd.read_file(shp)
crs_name = str(gdf.crs.srs)
logger.debug(f"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)
logger.info("Saving to temporary table")
# print("### shape file is ###")
lm2.save(strict=True, verbose=True)
logger.info("Save to temporary table completed")
os.remove(shp)
except Exception as e:
print('######## shape file##########',e)
try:
logger.debug("Attempting to read CSV file")
csv_f = glob.glob(r'{}/**/*.csv'.format(file_path), recursive=True)[0]
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])
# print(mdl)
# 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:
#heading = next(txt_file)
reader = csv.reader(txt_file, delimiter=",")
for fields in reader:
logger.debug(f"Processing row: {fields[0]}")
print("@@@@@@@@@@@@")
print(fields[0])
print("@@@@@@@@@@@@")
@ -925,26 +945,35 @@ def publish_data(sender, instance, created, **kwargs):
with open(csv_f, mode="r", encoding="utf-8") as txt_file:
reader_2 = csv.reader(txt_file, delimiter=",")
for fields in reader_2:
logger.debug(f"Inserting ShapeLayerLocation: {fields[0]}")
print("@@@@@@@@@@@@")
print(fields[0])
print("@@@@@@@@@@@@")
if instance.layerof == 1:
insertShapeLayerLocation(instance.name, fields)
logger.info("CSV processing completed")
except Exception as e:
print('######## csv file ##########',e)
def insertShapeLayerLocation(name, fields):
logger.info(f"Attempting to insert ShapeFileLocations for file: {name}, location_id: {fields[0]}")
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):
try:
with transaction.atomic():
sll = UserUploadUser(userfile=name, email=fields[0])
sll.save()
except Exception as e:
logger.error(f"Error updating TempLocation: {e}", exc_info=True)
@ -953,8 +982,9 @@ def updateLocation(mdl, fields):
print(mdl.objects.filter(location_id = int(fields[0])))
print(f"--- ${fields} ----")
try:
with transaction.atomic():
mdl.objects.filter(location_id = int(fields[0])).update(
updated = mdl.objects.filter(location_id = int(fields[0])).update(
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 '',
@ -995,6 +1025,11 @@ def updateLocation(mdl, fields):
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):
print(f"Updating {fields[0]} - {fields[1]}")
@ -1077,6 +1112,8 @@ def deleteUserUploadUser(sender,instance,*args,**kwargs):
@receiver(post_save, sender=UserUpload)
def publish_data(sender, instance, created, **kwargs):
logger.info(f"Processing ShapeLayer: {instance.name}")
file = instance.file.path
#os.remove(file)

View File

@ -0,0 +1,6 @@
こちらは岐阜aiネットワークです。
あなた様の岐阜ロゲエントリーが決定いたしましたことをお伝えいたします。
残暑厳しい中でのロゲイニングですが、水分補給をしっかり行ってご参加いただければ幸いです。
それでは、今後とも岐阜ロゲをよろしくお願いいたします。
本メールは送信専用のメールアドレスで送信しております。 本メールに返信いただいてもご回答いたしかねますので、あらかじめご了承くださいご質問等はinfo@gifuai.netまでお願いいたします。もしこのメールに心当たりがない場合は破棄願います。

View File

@ -14,3 +14,12 @@
よろしくお願いいたします。
{service_name} チーム
こちらは岐阜aiネットワークです。
このメールは招待者さんから、あなたへの、岐阜ロゲチームへの招待メールです。こちらをタップしていただければ招待者さんのチームの正式メンバーとして登録されます。https://xxx.xxxx.xxxxx
それでは、今後とも岐阜ロゲをよろしくお願いいたします。
本メールは送信専用のメールアドレスで送信しております。 本メールに返信いただいてもご回答いたしかねますので、あらかじめご了承くださいご質問等はinfo@gifuai.netまでお願いいたします。もしこのメールに心当たりがない場合は破棄願います。

View File

@ -14,3 +14,12 @@
よろしくお願いいたします。
{service_name} チーム
こちらは岐阜aiネットワークです。
このメールは招待者さんから、あなたへの、岐阜ロゲチームへの招待メールです。現在あなたは仮登録の状態ですので、まずは次のリンクをタップしてメンバーとして登録していただき、その後でこちらから岐阜ロゲアプリのダウンロードとインストール及び招待時のユーザー名でのログインをお願いします。個人情報を入力していただくことでチームに正式登録されます。https://xxx.xxxx.xxxxx
それでは、今後とも岐阜ロゲをよろしくお願いいたします。
本メールは送信専用のメールアドレスで送信しております。 本メールに返信いただいてもご回答いたしかねますので、あらかじめご了承くださいご質問等はinfo@gifuai.netまでお願いいたします。もしこのメールに心当たりがない場合は破棄願います。

View File

@ -14,3 +14,16 @@
よろしくお願いいたします。
{service_name} チーム
件名:岐阜ロゲのアクティベーション
{name} 様
こちらは岐阜aiネットワークです。
この度は岐阜ロゲアプリのダウンロードおよびユーザー登録、誠にありがとうございました。あなた様の登録で間違いがなければ、こちらをタップしログインページにお進みください。https://xxx.xxxx.xxxxx
それでは、今後とも岐阜ロゲをよろしくお願いいたします。
本メールは送信専用のメールアドレスで送信しております。 本メールに返信いただいてもご回答いたしかねますので、あらかじめご了承くださいご質問等はinfo@gifuai.netまでお願いいたします。もしこのメールに心当たりがない場合は破棄願います。
{service_name} チーム