From b68e6065d569da0f6dca011038306052e8d348eb Mon Sep 17 00:00:00 2001 From: Laurent Date: Wed, 25 Sep 2024 10:11:56 +0200 Subject: [PATCH] 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 = []