Fix Postgres error
This commit is contained in:
49
debug_events.py
Normal file
49
debug_events.py
Normal file
@ -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()
|
||||
11
rog/admin.py
11
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,
|
||||
|
||||
@ -4,6 +4,20 @@
|
||||
{% block content %}
|
||||
<h1>チェックポイントCSVアップロード</h1>
|
||||
|
||||
{% if user.is_staff %}
|
||||
<div class="messagelist">
|
||||
<div class="info">
|
||||
<strong>スタッフユーザー:</strong> 全ステータス(draft, private, public)のイベントが表示されます。
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="messagelist">
|
||||
<div class="info">
|
||||
<strong>一般ユーザー:</strong> publicステータスのイベントのみが表示されます。
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="module">
|
||||
<form method="post" enctype="multipart/form-data">
|
||||
{% csrf_token %}
|
||||
@ -14,7 +28,7 @@
|
||||
<select name="event" required>
|
||||
<option value="">-- イベントを選択 --</option>
|
||||
{% for event in events %}
|
||||
<option value="{{ event.id }}">{{ event.event_name }}</option>
|
||||
<option value="{{ event.id }}">{{ event.event_name }} ({{ event.status }})</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user