diff --git a/debug_events.py b/debug_events.py new file mode 100644 index 0000000..a94e298 --- /dev/null +++ b/debug_events.py @@ -0,0 +1,49 @@ +#!/usr/bin/env python +""" +Location2025とイベントの関係を調査するスクリプト +""" + +from rog.models import Location2025, NewEvent2 +from django.db import connection + +def main(): + print('=== Location2025とイベントの関係調査 ===') + + # Location2025のeventフィールドの外部キー先を確認 + event_field = Location2025._meta.get_field('event') + print(f'Location2025.event field references: {event_field.related_model}') + + # 現在のLocation2025データのイベント分布 + print('\n=== Location2025のイベント分布 ===') + cursor = connection.cursor() + cursor.execute(""" + SELECT l.event_id, ne.event_name, COUNT(*) as count + FROM rog_location2025 l + LEFT JOIN rog_newevent2 ne ON l.event_id = ne.id + GROUP BY l.event_id, ne.event_name + ORDER BY count DESC + """) + + for row in cursor.fetchall(): + event_id, event_name, count = row + print(f' Event ID {event_id}: {event_name} ({count}件)') + + # NewEvent2の一覧 + print('\n=== NewEvent2テーブルの全イベント ===') + for event in NewEvent2.objects.all()[:10]: + print(f' ID {event.id}: {event.event_name} (status: {event.status})') + + # CSVアップロード画面のイベント選択肢を確認 + print('\n=== CSVアップロード画面のイベント選択肢 ===') + events = NewEvent2.objects.filter(status='public').order_by('-start_datetime') + for event in events[:5]: + print(f' ID {event.id}: {event.event_name} (status: {event.status}, start: {event.start_datetime})') + + # 実際のLocation2025サンプルデータ + print('\n=== Location2025サンプルデータ ===') + sample_locations = Location2025.objects.all()[:3] + for loc in sample_locations: + print(f' CP{loc.cp_number}: {loc.cp_name} -> Event ID {loc.event_id} ({loc.event.event_name if loc.event else "None"})') + +if __name__ == '__main__': + main() diff --git a/rog/admin.py b/rog/admin.py index 9bdc5c4..eed014c 100755 --- a/rog/admin.py +++ b/rog/admin.py @@ -743,7 +743,7 @@ class LocationAdmin(LeafletGeoAdmin): search_fields = ('location_id', 'cp', 'location_name', 'category', 'event_name','group',) list_filter = ('event_name', 'group',) ordering = ('location_id', 'cp',) - list_display = ('location_id','sub_loc_id', 'cp', 'location_name', 'photos', 'category', 'group', 'event_name', 'event_active', 'auto_checkin', 'checkin_radius', 'checkin_point', 'buy_point',) + list_display = ('location_id','sub_loc_id', 'cp', 'location_name', 'photos', 'category', 'group', 'event_name', 'auto_checkin', 'checkin_radius', 'checkin_point', 'buy_point',) def tranfer_to_location(modeladmin, request, queryset): @@ -848,7 +848,7 @@ class TempLocationAdmin(LeafletGeoAdmin): search_fields = ('location_id', 'cp', 'location_name', 'category', 'event_name',) list_filter = ('category', 'event_name',) ordering = ('location_id', 'cp',) - list_display = ('location_id','cp', 'location_name', 'category', 'event_name', 'event_active', 'auto_checkin', 'checkin_radius', 'checkin_point', 'buy_point',) + list_display = ('location_id','cp', 'location_name', 'category', 'event_name', 'auto_checkin', 'checkin_radius', 'checkin_point', 'buy_point',) actions = [tranfer_to_location,] @@ -1158,8 +1158,11 @@ class Location2025Admin(LeafletGeoAdmin): # フォーム表示 - Location2025システム用 from .models import NewEvent2 - # statusフィールドベースでアクティブなイベントを取得 - events = NewEvent2.objects.filter(status='public').order_by('-start_datetime') + # スタッフユーザーの場合は全ステータスのイベントを表示 + if request.user.is_staff: + events = NewEvent2.objects.all().order_by('-start_datetime') + else: + events = NewEvent2.objects.filter(status='public').order_by('-start_datetime') return render(request, 'admin/location2025/upload_csv.html', { 'events': events, diff --git a/templates/admin/location2025/upload_csv.html b/templates/admin/location2025/upload_csv.html index b61c123..29f5cfb 100644 --- a/templates/admin/location2025/upload_csv.html +++ b/templates/admin/location2025/upload_csv.html @@ -4,6 +4,20 @@ {% block content %}