From aca3a3a9ac8a7320382f5e2ffa4c6956113a05e7 Mon Sep 17 00:00:00 2001 From: Laurent Date: Sat, 1 Feb 2025 14:39:47 +0100 Subject: [PATCH 1/2] fix crash --- tournaments/models/tournament.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tournaments/models/tournament.py b/tournaments/models/tournament.py index d8ac5a2..7126885 100644 --- a/tournaments/models/tournament.py +++ b/tournaments/models/tournament.py @@ -734,7 +734,7 @@ class Tournament(models.Model): # all started matches have ended, possibly last_finished_match = self.last_finished_match() - if last_finished_match: + if last_finished_match and last_finished_match.round: # print(f'last_finished_match = {last_finished_match.name}') round_root_index = last_finished_match.round.root_round().index # print(f'round_index = {round_root_index}') From af3026bd9be35730a8d2d83bc4013fa506ccaa41 Mon Sep 17 00:00:00 2001 From: Laurent Date: Sat, 1 Feb 2025 14:53:00 +0100 Subject: [PATCH 2/2] Fix issue --- tournaments/models/tournament.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tournaments/models/tournament.py b/tournaments/models/tournament.py index f91903f..e0fc064 100644 --- a/tournaments/models/tournament.py +++ b/tournaments/models/tournament.py @@ -733,12 +733,17 @@ class Tournament(models.Model): # all started matches have ended, possibly last_finished_match = self.last_finished_match() - if last_finished_match and last_finished_match.round: + + round = last_finished_match.round + if round is None: # when the last finished match is in the group stage + round = self.round_set.filter(parent__isnull=True).order_by('-index').first() + + if round: # print(f'last_finished_match = {last_finished_match.name}') - round_root_index = last_finished_match.round.root_round().index + round_root_index = round.root_round().index # print(f'round_index = {round_root_index}') if round_root_index == 0: - return last_finished_match.round + return round else: round = self.round_set.filter(parent=None,index=round_root_index-1).first() if round: