almost finish migrate new circumstances
This commit is contained in:
87
test_step1.py
Normal file
87
test_step1.py
Normal file
@ -0,0 +1,87 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
手順1: 大垣3イベントを検索して大垣テストイベントを作成
|
||||
"""
|
||||
import os
|
||||
import sys
|
||||
import django
|
||||
|
||||
# Django設定
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings')
|
||||
django.setup()
|
||||
|
||||
from rog.models import *
|
||||
from django.utils import timezone
|
||||
from datetime import datetime, timedelta
|
||||
from django.contrib.gis.geos import Point
|
||||
|
||||
def create_test_event():
|
||||
print("=== 手順1: 大垣3イベントを複製して大垣テストイベントを作成 ===")
|
||||
|
||||
# 大垣3イベントを検索
|
||||
ogaki3 = NewEvent2.objects.filter(event_name__contains="大垣3").first()
|
||||
if ogaki3:
|
||||
print(f"大垣3イベント見つかりました: {ogaki3.event_name} (ID: {ogaki3.id})")
|
||||
|
||||
# 大垣テストイベントを作成(既存を削除してから)
|
||||
NewEvent2.objects.filter(event_name="大垣テスト").delete()
|
||||
print("既存の大垣テストイベントを削除しました")
|
||||
|
||||
test_event = NewEvent2.objects.create(
|
||||
event_name="大垣テスト",
|
||||
event_description="大垣3のテスト用複製イベント",
|
||||
public=True,
|
||||
hour_5=True,
|
||||
class_general=True,
|
||||
class_family=True,
|
||||
start_datetime=timezone.now() + timedelta(hours=1),
|
||||
end_datetime=timezone.now() + timedelta(hours=8),
|
||||
event_code="OGAKI_TEST",
|
||||
start_time=(timezone.now() + timedelta(hours=1)).strftime("%H:%M"),
|
||||
event_day=timezone.now().strftime("%Y-%m-%d"),
|
||||
venue_address="岐阜県大垣市(テスト用)"
|
||||
)
|
||||
print(f"「大垣テスト」イベントを作成しました (ID: {test_event.id})")
|
||||
|
||||
# 大垣3のLocationデータをコピー
|
||||
locations = Location.objects.filter(event=ogaki3)
|
||||
print(f"大垣3には{locations.count()}個のLocationがあります")
|
||||
|
||||
location_mapping = {}
|
||||
for loc in locations:
|
||||
new_loc = Location.objects.create(
|
||||
event=test_event,
|
||||
point_no=loc.point_no,
|
||||
point_name=loc.point_name,
|
||||
point_name_en=loc.point_name_en,
|
||||
content=loc.content,
|
||||
content_en=loc.content_en,
|
||||
note=loc.note,
|
||||
note_en=loc.note_en,
|
||||
location=loc.location, # PostGISのPointFieldをコピー
|
||||
access_way=loc.access_way,
|
||||
point=loc.point if hasattr(loc, 'point') else 100,
|
||||
map_url=loc.map_url,
|
||||
qr_code=loc.qr_code,
|
||||
image=loc.image
|
||||
)
|
||||
location_mapping[loc.id] = new_loc.id
|
||||
print(f"Location {loc.point_no}: {loc.point_name} -> {new_loc.id}")
|
||||
|
||||
print(f"Location複製完了: {len(location_mapping)}個")
|
||||
return test_event, location_mapping
|
||||
else:
|
||||
print("大垣3イベントが見つかりません")
|
||||
# 利用可能なイベントを表示
|
||||
events = NewEvent2.objects.all()[:10]
|
||||
print("利用可能なイベント:")
|
||||
for event in events:
|
||||
print(f" - {event.event_name} (ID: {event.id})")
|
||||
return None, {}
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_event, location_mapping = create_test_event()
|
||||
if test_event:
|
||||
print(f"\n✅ 手順1完了: {test_event.event_name} (ID: {test_event.id}) を作成しました")
|
||||
else:
|
||||
print("\n❌ 手順1失敗: 大垣3イベントが見つかりませんでした")
|
||||
Reference in New Issue
Block a user