diff --git a/rog/models.py b/rog/models.py index 52ce5ab..b04bc5a 100644 --- a/rog/models.py +++ b/rog/models.py @@ -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,76 +945,91 @@ 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): - sll = UserUploadUser(userfile=name, email=fields[0]) - sll.save(); + 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): - with transaction.atomic(): - sll = UserUploadUser(userfile=name, email=fields[0]) - sll.save() - + 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) + def updateLocation(mdl, fields): print(f"Updating {fields[0]} - {fields[1]}") print(mdl.objects.filter(location_id = int(fields[0]))) 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 '', - 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 '', - subcategory = fields[5] if len(fields[5]) > 0 else '', - zip = fields[6] if len(fields[6]) > 0 else '', - address = fields[7] if len(fields[7]) > 0 else '', - prefecture = fields[8] if len(fields[8]) > 0 else '', - area = fields[9] if len(fields[9]) > 0 else '', - city = fields[10] if len(fields[10]) > 0 else '', - latitude = fields[11] if len(fields[11]) > 0 else '', - longitude = fields[12] if len(fields[12]) > 0 else '', - photos = fields[13] if len(fields[13]) > 0 else '', - videos = fields[14] if len(fields[14]) > 0 else '', - webcontents = fields[15] if len(fields[15]) > 0 else '', - status = fields[16] if len(fields[16]) > 0 else '', - portal = fields[17] if len(fields[17]) > 0 else '', - group = fields[18] if len(fields[18]) > 0 else '', - phone = fields[19] if len(fields[19]) > 0 else '', - fax = fields[20] if len(fields[20]) > 0 else '', - email = fields[21] if len(fields[21]) > 0 else '', - facility = fields[22] if len(fields[22]) > 0 else '', - remark = fields[23] if len(fields[23]) > 0 else '', - tags = fields[24] if len(fields[24]) > 0 else '', - hidden_location = fields[25] if len(fields[25]) > 0 else False, - auto_checkin = fields[26] if len(fields[26]) > 0 else False, - checkin_radius = fields[27] if len(fields[27]) > 0 else 15, - checkin_point = fields[28] if len(fields[28]) > 0 else 10, - buy_point = fields[29] if len(fields[29]) > 0 else 0, - evaluation_value = fields[30] if len(fields[30]) > 0 else '', - shop_closed = fields[31] if len(fields[31]) > 0 else False, - shop_shutdown = fields[32] if len(fields[32]) > 0 else False, - opening_hours_mon = fields[33] if len(fields[33]) > 0 else '', - opening_hours_tue = fields[34] if len(fields[34]) > 0 else '', - opening_hours_wed = fields[35] if len(fields[35]) > 0 else '', - opening_hours_thu = fields[36] if len(fields[36]) > 0 else '', - opening_hours_fri = fields[37] if len(fields[37]) > 0 else '', - opening_hours_sat = fields[38] if len(fields[38]) > 0 else '', - opening_hours_sun = fields[39] if len(fields[39]) > 0 else '' - ) + + try: + with transaction.atomic(): + 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 '', + category = fields[4] if len(fields[4]) > 0 else '', + subcategory = fields[5] if len(fields[5]) > 0 else '', + zip = fields[6] if len(fields[6]) > 0 else '', + address = fields[7] if len(fields[7]) > 0 else '', + prefecture = fields[8] if len(fields[8]) > 0 else '', + area = fields[9] if len(fields[9]) > 0 else '', + city = fields[10] if len(fields[10]) > 0 else '', + latitude = fields[11] if len(fields[11]) > 0 else '', + longitude = fields[12] if len(fields[12]) > 0 else '', + photos = fields[13] if len(fields[13]) > 0 else '', + videos = fields[14] if len(fields[14]) > 0 else '', + webcontents = fields[15] if len(fields[15]) > 0 else '', + status = fields[16] if len(fields[16]) > 0 else '', + portal = fields[17] if len(fields[17]) > 0 else '', + group = fields[18] if len(fields[18]) > 0 else '', + phone = fields[19] if len(fields[19]) > 0 else '', + fax = fields[20] if len(fields[20]) > 0 else '', + email = fields[21] if len(fields[21]) > 0 else '', + facility = fields[22] if len(fields[22]) > 0 else '', + remark = fields[23] if len(fields[23]) > 0 else '', + tags = fields[24] if len(fields[24]) > 0 else '', + hidden_location = fields[25] if len(fields[25]) > 0 else False, + auto_checkin = fields[26] if len(fields[26]) > 0 else False, + checkin_radius = fields[27] if len(fields[27]) > 0 else 15, + checkin_point = fields[28] if len(fields[28]) > 0 else 10, + buy_point = fields[29] if len(fields[29]) > 0 else 0, + evaluation_value = fields[30] if len(fields[30]) > 0 else '', + shop_closed = fields[31] if len(fields[31]) > 0 else False, + shop_shutdown = fields[32] if len(fields[32]) > 0 else False, + opening_hours_mon = fields[33] if len(fields[33]) > 0 else '', + opening_hours_tue = fields[34] if len(fields[34]) > 0 else '', + opening_hours_wed = fields[35] if len(fields[35]) > 0 else '', + opening_hours_thu = fields[36] if len(fields[36]) > 0 else '', + opening_hours_fri = fields[37] if len(fields[37]) > 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): 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) diff --git a/rog/templates/email/entry_notification_email.txt b/rog/templates/email/entry_notification_email.txt new file mode 100644 index 0000000..346fa0d --- /dev/null +++ b/rog/templates/email/entry_notification_email.txt @@ -0,0 +1,6 @@ +こちらは岐阜aiネットワークです。 +あなた様の岐阜ロゲエントリーが決定いたしましたことをお伝えいたします。 +残暑厳しい中でのロゲイニングですが、水分補給をしっかり行ってご参加いただければ幸いです。 +それでは、今後とも岐阜ロゲをよろしくお願いいたします。 + +本メールは送信専用のメールアドレスで送信しております。 本メールに返信いただいてもご回答いたしかねますので、あらかじめご了承ください(ご質問等はinfo@gifuai.netまでお願いいたします)。もしこのメールに心当たりがない場合は破棄願います。 diff --git a/rog/templates/email/invitation_existing_email.txt b/rog/templates/email/invitation_existing_email.txt index 24f0cc7..d1ec4e5 100644 --- a/rog/templates/email/invitation_existing_email.txt +++ b/rog/templates/email/invitation_existing_email.txt @@ -14,3 +14,12 @@ よろしくお願いいたします。 {service_name} チーム + + +こちらは岐阜aiネットワークです。 +このメールは{{招待者}}さんから、あなたへの、岐阜ロゲチームへの招待メールです。こちらをタップしていただければ{{招待者}}さんのチームの正式メンバーとして登録されます。https://xxx.xxxx.xxxxx +それでは、今後とも岐阜ロゲをよろしくお願いいたします。 + +本メールは送信専用のメールアドレスで送信しております。 本メールに返信いただいてもご回答いたしかねますので、あらかじめご了承ください(ご質問等はinfo@gifuai.netまでお願いいたします)。もしこのメールに心当たりがない場合は破棄願います。 + + diff --git a/rog/templates/email/invitation_new_email.txt b/rog/templates/email/invitation_new_email.txt index 24f0cc7..1fad263 100644 --- a/rog/templates/email/invitation_new_email.txt +++ b/rog/templates/email/invitation_new_email.txt @@ -14,3 +14,12 @@ よろしくお願いいたします。 {service_name} チーム + + +こちらは岐阜aiネットワークです。 +このメールは{{招待者}}さんから、あなたへの、岐阜ロゲチームへの招待メールです。現在あなたは仮登録の状態ですので、まずは次のリンクをタップしてメンバーとして登録していただき、その後でこちらから岐阜ロゲアプリのダウンロードとインストール及び招待時のユーザー名でのログインをお願いします。個人情報を入力していただくことでチームに正式登録されます。https://xxx.xxxx.xxxxx +それでは、今後とも岐阜ロゲをよろしくお願いいたします。 + +本メールは送信専用のメールアドレスで送信しております。 本メールに返信いただいてもご回答いたしかねますので、あらかじめご了承ください(ご質問等はinfo@gifuai.netまでお願いいたします)。もしこのメールに心当たりがない場合は破棄願います。 + + diff --git a/rog/templates/email/verification_email.txt b/rog/templates/email/verification_email.txt index 67a37a0..99fff88 100644 --- a/rog/templates/email/verification_email.txt +++ b/rog/templates/email/verification_email.txt @@ -14,3 +14,16 @@ よろしくお願いいたします。 {service_name} チーム + + +件名:岐阜ロゲのアクティベーション +{name} 様 + +こちらは岐阜aiネットワークです。 +この度は岐阜ロゲアプリのダウンロードおよびユーザー登録、誠にありがとうございました。あなた様の登録で間違いがなければ、こちらをタップしログインページにお進みください。https://xxx.xxxx.xxxxx +それでは、今後とも岐阜ロゲをよろしくお願いいたします。 + +本メールは送信専用のメールアドレスで送信しております。 本メールに返信いただいてもご回答いたしかねますので、あらかじめご了承ください(ご質問等はinfo@gifuai.netまでお願いいたします)。もしこのメールに心当たりがない場合は破棄願います。 + + +{service_name} チーム