Fix inbound2 fields missing
This commit is contained in:
BIN
rog/.DS_Store
vendored
BIN
rog/.DS_Store
vendored
Binary file not shown.
@ -54,25 +54,201 @@ class LocationSerializer(serializers.ModelSerializer):
|
|||||||
latitude_float = serializers.SerializerMethodField()
|
latitude_float = serializers.SerializerMethodField()
|
||||||
longitude_float = serializers.SerializerMethodField()
|
longitude_float = serializers.SerializerMethodField()
|
||||||
|
|
||||||
|
# フィールド名の別名対応
|
||||||
|
webcontent = serializers.SerializerMethodField()
|
||||||
|
zip = serializers.SerializerMethodField()
|
||||||
|
s3_name = serializers.SerializerMethodField()
|
||||||
|
|
||||||
|
def get_webcontent(self, obj):
|
||||||
|
"""websiteフィールドをwebcontentとして返す"""
|
||||||
|
return obj.website
|
||||||
|
|
||||||
|
def get_zip(self, obj):
|
||||||
|
"""zip_codeフィールドをzipとして返す"""
|
||||||
|
return obj.zip_code
|
||||||
|
|
||||||
|
def get_s3_name(self, obj):
|
||||||
|
"""S3ファイル名を生成して返す(event_nameのローマ字表記)"""
|
||||||
|
if not obj.event:
|
||||||
|
return None
|
||||||
|
|
||||||
|
# NewEvent2のs3_nameフィールドを参照
|
||||||
|
if hasattr(obj.event, 's3_name') and obj.event.s3_name:
|
||||||
|
return obj.event.s3_name
|
||||||
|
|
||||||
|
# フォールバック: event_nameをローマ字に変換
|
||||||
|
if obj.event.event_name:
|
||||||
|
s3_name = self._convert_japanese_to_romaji(obj.event.event_name)
|
||||||
|
return s3_name
|
||||||
|
|
||||||
|
# 最終フォールバック: イベントコード
|
||||||
|
return obj.event.event_code
|
||||||
|
|
||||||
|
def _convert_japanese_to_romaji(self, japanese_text):
|
||||||
|
"""日本語をローマ字に変換する"""
|
||||||
|
# 基本的な日本語→ローマ字変換テーブル
|
||||||
|
conversion_table = {
|
||||||
|
# 地名
|
||||||
|
'岐阜': 'gifu',
|
||||||
|
'大垣': 'ogaki',
|
||||||
|
'多治見': 'tajimi',
|
||||||
|
'関': 'seki',
|
||||||
|
'中津川': 'nakatsugawa',
|
||||||
|
'美濃': 'mino',
|
||||||
|
'瑞浪': 'mizunami',
|
||||||
|
'羽島': 'hashima',
|
||||||
|
'恵那': 'ena',
|
||||||
|
'美濃加茂': 'minokamo',
|
||||||
|
'土岐': 'toki',
|
||||||
|
'各務原': 'kakamigahara',
|
||||||
|
'可児': 'kani',
|
||||||
|
'山県': 'yamagata',
|
||||||
|
'瑞穂': 'mizuho',
|
||||||
|
'飛騨': 'hida',
|
||||||
|
'本巣': 'motosu',
|
||||||
|
'郡上': 'gujo',
|
||||||
|
'下呂': 'gero',
|
||||||
|
'海津': 'kaizu',
|
||||||
|
|
||||||
|
# 一般的な単語
|
||||||
|
'ロゲイニング': 'rogaining',
|
||||||
|
'ロゲ': 'roge',
|
||||||
|
'イベント': 'event',
|
||||||
|
'大会': 'taikai',
|
||||||
|
'競技': 'kyogi',
|
||||||
|
'スポーツ': 'sports',
|
||||||
|
'アウトドア': 'outdoor',
|
||||||
|
'ハイキング': 'hiking',
|
||||||
|
'ウォーキング': 'walking',
|
||||||
|
'ランニング': 'running',
|
||||||
|
'マラソン': 'marathon',
|
||||||
|
'トレイル': 'trail',
|
||||||
|
'オリエンテーリング': 'orienteering',
|
||||||
|
'ナビゲーション': 'navigation',
|
||||||
|
'チェックポイント': 'checkpoint',
|
||||||
|
'ゴール': 'goal',
|
||||||
|
'スタート': 'start',
|
||||||
|
'チーム': 'team',
|
||||||
|
'ファミリー': 'family',
|
||||||
|
'ジュニア': 'junior',
|
||||||
|
'シニア': 'senior',
|
||||||
|
'初心者': 'beginner',
|
||||||
|
'上級者': 'advanced',
|
||||||
|
'中級者': 'intermediate',
|
||||||
|
|
||||||
|
# 年号
|
||||||
|
'2025': '2025',
|
||||||
|
'2025': '2025',
|
||||||
|
'2024': '2024',
|
||||||
|
'2024': '2024',
|
||||||
|
'2026': '2026',
|
||||||
|
'2026': '2026',
|
||||||
|
'2027': '2027',
|
||||||
|
'2027': '2027',
|
||||||
|
'2028': '2028',
|
||||||
|
'2028': '2028',
|
||||||
|
'2029': '2029',
|
||||||
|
'2029': '2029',
|
||||||
|
'2030': '2030',
|
||||||
|
'2030': '2030',
|
||||||
|
|
||||||
|
# 月
|
||||||
|
'1月': 'january',
|
||||||
|
'2月': 'february',
|
||||||
|
'3月': 'march',
|
||||||
|
'4月': 'april',
|
||||||
|
'5月': 'may',
|
||||||
|
'6月': 'june',
|
||||||
|
'7月': 'july',
|
||||||
|
'8月': 'august',
|
||||||
|
'9月': 'september',
|
||||||
|
'10月': 'october',
|
||||||
|
'11月': 'november',
|
||||||
|
'12月': 'december',
|
||||||
|
|
||||||
|
# その他
|
||||||
|
'春': 'spring',
|
||||||
|
'夏': 'summer',
|
||||||
|
'秋': 'autumn',
|
||||||
|
'冬': 'winter',
|
||||||
|
'第': 'dai',
|
||||||
|
'回': 'kai',
|
||||||
|
'杯': 'hai',
|
||||||
|
'記念': 'kinen',
|
||||||
|
'特別': 'tokubetsu',
|
||||||
|
'公式': 'koshiki',
|
||||||
|
'練習': 'renshu',
|
||||||
|
'体験': 'taiken'
|
||||||
|
}
|
||||||
|
|
||||||
|
result = japanese_text.lower()
|
||||||
|
|
||||||
|
# 変換テーブルを使用して変換
|
||||||
|
for japanese, romaji in conversion_table.items():
|
||||||
|
result = result.replace(japanese, romaji)
|
||||||
|
|
||||||
|
# 記号の変換
|
||||||
|
result = result.replace(' ', '_')
|
||||||
|
result = result.replace('-', '_')
|
||||||
|
result = result.replace(' ', '_') # 全角スペース
|
||||||
|
result = result.replace('・', '_')
|
||||||
|
result = result.replace('/', '_')
|
||||||
|
result = result.replace('\\', '_')
|
||||||
|
result = result.replace('(', '_')
|
||||||
|
result = result.replace(')', '_')
|
||||||
|
result = result.replace('(', '_')
|
||||||
|
result = result.replace(')', '_')
|
||||||
|
result = result.replace('[', '_')
|
||||||
|
result = result.replace(']', '_')
|
||||||
|
result = result.replace('【', '_')
|
||||||
|
result = result.replace('】', '_')
|
||||||
|
result = result.replace(':', '_')
|
||||||
|
result = result.replace(':', '_')
|
||||||
|
result = result.replace(';', '_')
|
||||||
|
result = result.replace(';', '_')
|
||||||
|
result = result.replace(',', '_')
|
||||||
|
result = result.replace(',', '_')
|
||||||
|
result = result.replace('.', '_')
|
||||||
|
result = result.replace('。', '_')
|
||||||
|
result = result.replace('!', '_')
|
||||||
|
result = result.replace('!', '_')
|
||||||
|
result = result.replace('?', '_')
|
||||||
|
result = result.replace('?', '_')
|
||||||
|
|
||||||
|
# 連続するアンダースコアを単一に
|
||||||
|
while '__' in result:
|
||||||
|
result = result.replace('__', '_')
|
||||||
|
|
||||||
|
# 先頭と末尾のアンダースコアを削除
|
||||||
|
result = result.strip('_')
|
||||||
|
|
||||||
|
# 空文字列の場合は'event'を返す
|
||||||
|
if not result:
|
||||||
|
result = 'event'
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model=Location2025
|
model=Location2025
|
||||||
fields=[
|
fields=[
|
||||||
# 基本フィールド
|
# 基本フィールド
|
||||||
'id', 'cp_number', 'event', 'cp_name', 'sub_loc_id', 'subcategory',
|
'id', 'cp_number', 'event', 'cp_name', 's3_name','category', 'sub_loc_id', 'subcategory',
|
||||||
'latitude', 'longitude', 'location', 'address',
|
'latitude', 'longitude', 'location', 'address',
|
||||||
'checkin_point', 'buy_point',
|
'checkin_point', 'buy_point',
|
||||||
'checkin_radius', 'auto_checkin',
|
'checkin_radius', 'auto_checkin',
|
||||||
'shop_closed', 'shop_shutdown', 'opening_hours',
|
'shop_closed', 'shop_shutdown', 'opening_hours',
|
||||||
'phone', 'website', 'description', 'remark',
|
'phone', 'website', 'facility', 'description', 'remark',
|
||||||
|
# 住所詳細フィールド
|
||||||
|
'zip_code', 'prefecture', 'area', 'city',
|
||||||
# 追加フィールド
|
# 追加フィールド
|
||||||
'photos', 'videos', 'tags', 'evaluation_value', 'hidden_location',
|
'photos', 'videos', 'tags', 'evaluation_value', 'hidden_location',
|
||||||
# 管理フィールド
|
# 管理フィールド
|
||||||
'is_active', 'sort_order', 'csv_source_file', 'csv_upload_date',
|
'is_active', 'sort_order', 'csv_source_file', 'csv_upload_date', 'csv_upload_user',
|
||||||
'created_at', 'updated_at', 'created_by', 'updated_by',
|
'created_at', 'updated_at', 'created_by', 'updated_by',
|
||||||
# カスタムフィールド
|
# カスタムフィールド
|
||||||
'interaction_type', 'requires_photo', 'requires_qr_code', 'interaction_instructions',
|
'interaction_type', 'requires_photo', 'requires_qr_code', 'interaction_instructions',
|
||||||
'has_photos', 'has_videos', 'photos_list', 'videos_list', 'tags_list',
|
'has_photos', 'has_videos', 'photos_list', 'videos_list', 'tags_list',
|
||||||
'latitude_float', 'longitude_float'
|
'latitude_float', 'longitude_float', 'webcontent', 'zip'
|
||||||
]
|
]
|
||||||
|
|
||||||
def get_latitude_float(self, obj):
|
def get_latitude_float(self, obj):
|
||||||
@ -150,7 +326,7 @@ class LocationSerializer(serializers.ModelSerializer):
|
|||||||
if evaluation_value == "1":
|
if evaluation_value == "1":
|
||||||
return "商品の写真を撮影してください。買い物をすることでポイントを獲得できます"
|
return "商品の写真を撮影してください。買い物をすることでポイントを獲得できます"
|
||||||
elif evaluation_value == "2":
|
elif evaluation_value == "2":
|
||||||
return "QRコードをスキャンしてクイズに答えてください"
|
return "QRコードをスキャンしてください"
|
||||||
else:
|
else:
|
||||||
return "この場所でチェックインしてポイントを獲得してください"
|
return "この場所でチェックインしてポイントを獲得してください"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user