From cdae8dc7ec46d7e59faa739defc5b5eb2c32d12f Mon Sep 17 00:00:00 2001 From: Akira Date: Mon, 11 Nov 2024 15:58:05 +0900 Subject: [PATCH] Fix MyAlbum code step5 --- rog/views.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/rog/views.py b/rog/views.py index 4ec7f31..83ec140 100644 --- a/rog/views.py +++ b/rog/views.py @@ -2696,6 +2696,10 @@ def get_photo_list(request): "message": "Missing required parameters: zekken and event" }, status=400) + # イベントコードからダブルクォートを削除 + event = event.strip('"') + zekken = zekken.strip('"') + zekken_conversion = { "MF3-160": "MZ3-160", "MF3-161": "MZ3-161", @@ -2744,6 +2748,25 @@ def _get_photo_list(zekken, event_code): for checkin in checkins: print(f"Processing checkin - CP number: {checkin.cp_number}") + if checkin.image_address: + # URLオブジェクトかどうかを判定して適切なURLを生成 + if hasattr(checkin.image_address, 'url'): + photo_url = checkin.image_address.url + else: + # 文字列の場合は先頭にベースURLを追加 + photo_url = f"http://rogaining.sumasen.net/media/{checkin.image_address}" + + print(f"Found image for CP {checkin.cp_number}: {photo_url}") + photos.append({ + "cp_number": checkin.cp_number, + "photo_url": photo_url + }) + else: + print(f"No image found for CP {checkin.cp_number}") + + + + if checkin.image_address: print(f"Found image for CP {checkin.cp_number}: {checkin.image_address.url}") photos.append({ @@ -2754,7 +2777,7 @@ def _get_photo_list(zekken, event_code): print(f"No image found for CP {checkin.cp_number}") print(f"Total photos found: {len(photos)}") - + except Exception as e: print(f"Error in _get_photo_list: {str(e)}") return photos