avoid exception on game overview when sessions are 0
Django CI/CD / test (push) Successful in 1m7s Details
Django CI/CD / build-and-push (push) Successful in 2m7s Details

This commit is contained in:
Lukáš Kucharczyk 2024-10-04 10:17:38 +02:00
parent 10e96bbc88
commit 7f5a1889f3
Signed by: lukas
SSH Key Fingerprint: SHA256:vMuSwvwAvcT6htVAioMP7rzzwMQNi3roESyhv+nAxeg
1 changed files with 6 additions and 2 deletions

View File

@ -273,6 +273,8 @@ def view_game(request: HttpRequest, game_id: int) -> HttpResponse:
sessions_all = Session.objects.filter(purchase__edition__game=game).order_by( sessions_all = Session.objects.filter(purchase__edition__game=game).order_by(
"-timestamp_start" "-timestamp_start"
) )
last_session = None
if sessions_all.exists():
last_session = sessions_all.latest() last_session = sessions_all.latest()
session_count = sessions_all.count() session_count = sessions_all.count()
session_paginator = Paginator(sessions_all, 5) session_paginator = Paginator(sessions_all, 5)
@ -310,7 +312,9 @@ def view_game(request: HttpRequest, game_id: int) -> HttpResponse:
) )
], ],
), ),
), )
if last_session
else "",
], ],
), ),
"columns": ["Edition", "Date", "Duration", "Actions"], "columns": ["Edition", "Date", "Duration", "Actions"],