Fix MyAlbum code step6
This commit is contained in:
26
rog/views.py
26
rog/views.py
@ -2749,12 +2749,16 @@ 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を生成
|
||||
# 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}"
|
||||
# 文字列の場合、httpで始まるかどうかを確認
|
||||
image_address_str = str(checkin.image_address)
|
||||
if image_address_str.lower().startswith('http'):
|
||||
photo_url = image_address_str
|
||||
else:
|
||||
photo_url = f"http://rogaining.sumasen.net/media/{image_address_str}"
|
||||
|
||||
print(f"Found image for CP {checkin.cp_number}: {photo_url}")
|
||||
photos.append({
|
||||
@ -2763,20 +2767,8 @@ def _get_photo_list(zekken, event_code):
|
||||
})
|
||||
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({
|
||||
"cp_number": checkin.cp_number,
|
||||
"photo_url": checkin.image_address.url
|
||||
})
|
||||
else:
|
||||
print(f"No image found for CP {checkin.cp_number}")
|
||||
|
||||
print(f"Total photos found: {len(photos)}")
|
||||
|
||||
print(f"Total photos found: {len(photos)}")
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error in _get_photo_list: {str(e)}")
|
||||
|
||||
Reference in New Issue
Block a user