From 6be8dc3667acc20997f2af2f557a2d29eb4950a3 Mon Sep 17 00:00:00 2001 From: Laurent Date: Wed, 25 Sep 2024 10:07:54 +0200 Subject: [PATCH 1/3] 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 e11eea1..df11972 100644 --- a/tournaments/models/tournament.py +++ b/tournaments/models/tournament.py @@ -549,7 +549,7 @@ class Tournament(models.Model): def last_started_match(self): matches = [m for m in self.all_matches(False) if m.start_date] matches.sort(key=lambda m: m.start_date, reverse=True) - return matches[0] + return matches.get(0) # get returns None if not present def round_for_index(self, index): return self.round_set.filter(index=index, parent=None).first() From 34f605a67766c8a14242419f0b40dfd0f16f104d Mon Sep 17 00:00:00 2001 From: Laurent Date: Wed, 25 Sep 2024 10:09:43 +0200 Subject: [PATCH 2/3] Fix crash in the broadcast --- tournaments/models/tournament.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/tournaments/models/tournament.py b/tournaments/models/tournament.py index df11972..8770db8 100644 --- a/tournaments/models/tournament.py +++ b/tournaments/models/tournament.py @@ -87,16 +87,12 @@ class Tournament(models.Model): def display_name(self): if self.name: - if self.federal_level_category == FederalLevelCategory.UNLISTED: - return self.name return self.base_name() + " " + self.name else: return self.base_name() def broadcast_display_name(self): if self.name: - if self.federal_level_category == FederalLevelCategory.UNLISTED: - return self.name return self.short_base_name() + " " + self.name else: return self.base_name() @@ -557,7 +553,7 @@ class Tournament(models.Model): def first_round(self): main_rounds = list(self.round_set.filter(parent=None)) main_rounds.sort(key=lambda r: r.index, reverse=True) - return main_rounds[0] + return main_rounds.get(0) # get returns None if not present def broadcasted_group_stages_matches(self): matches = [] From b68e6065d569da0f6dca011038306052e8d348eb Mon Sep 17 00:00:00 2001 From: Laurent Date: Wed, 25 Sep 2024 10:11:56 +0200 Subject: [PATCH 3/3] Fix crash again --- tournaments/models/tournament.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tournaments/models/tournament.py b/tournaments/models/tournament.py index 8770db8..60cb799 100644 --- a/tournaments/models/tournament.py +++ b/tournaments/models/tournament.py @@ -545,7 +545,7 @@ class Tournament(models.Model): def last_started_match(self): matches = [m for m in self.all_matches(False) if m.start_date] matches.sort(key=lambda m: m.start_date, reverse=True) - return matches.get(0) # get returns None if not present + return matches[0] if matches else None def round_for_index(self, index): return self.round_set.filter(index=index, parent=None).first() @@ -553,7 +553,7 @@ class Tournament(models.Model): def first_round(self): main_rounds = list(self.round_set.filter(parent=None)) main_rounds.sort(key=lambda r: r.index, reverse=True) - return main_rounds.get(0) # get returns None if not present + return main_rounds[0] if main_rounds else None def broadcasted_group_stages_matches(self): matches = []