From 7d23fa68d05e5a79e6fe8e1bb4b7c682ce703bc1 Mon Sep 17 00:00:00 2001 From: Laurent Date: Fri, 15 Mar 2024 09:44:51 +0100 Subject: [PATCH] filter matches by name --- tournaments/models/tournament.py | 9 ++++++--- .../templates/tournaments/broadcasted_matches.html | 2 +- tournaments/views.py | 4 ++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/tournaments/models/tournament.py b/tournaments/models/tournament.py index 3378b22..eba470b 100644 --- a/tournaments/models/tournament.py +++ b/tournaments/models/tournament.py @@ -68,7 +68,7 @@ class Tournament(models.Model): return summons - def live_matches(self): + def live_matches(self, broadcasted): matches = [] for group_stage in self.groupstage_set.all(): for match in group_stage.match_set.all(): @@ -77,8 +77,11 @@ class Tournament(models.Model): for match in round.match_set.all(): matches.append(match) - matches = [m for m in matches if m.broadcasted==True] - # matches = [m for m in matches if len(m.team_scores.all()) > 0] + if broadcasted: + matches = [m for m in matches if m.broadcasted==True] + if not broadcasted: + matches = [m for m in matches if len(m.team_scores.all()) > 0] + matches.sort(key=lambda m: m.order) return [match.live_match() for match in matches] diff --git a/tournaments/templates/tournaments/broadcasted_matches.html b/tournaments/templates/tournaments/broadcasted_matches.html index f01256d..9af969d 100644 --- a/tournaments/templates/tournaments/broadcasted_matches.html +++ b/tournaments/templates/tournaments/broadcasted_matches.html @@ -70,7 +70,7 @@
- +