From 6e11af3328705a101a44bb96e3303f858464da2c Mon Sep 17 00:00:00 2001 From: Razmig Sarkissian Date: Thu, 30 May 2024 19:20:45 +0200 Subject: [PATCH] round hide empty matches --- tournaments/models/round.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tournaments/models/round.py b/tournaments/models/round.py index 5cb54eb..fa22f55 100644 --- a/tournaments/models/round.py +++ b/tournaments/models/round.py @@ -35,7 +35,11 @@ class Round(models.Model): for child in self.children.all(): child_matches = child.match_set.all() - child_matches = [m for m in child_matches if m.should_appear()] + if hide_empty_matches: + child_matches = [m for m in child_matches if m.should_appear()] + else: + child_matches = [m for m in child_matches if m.disabled is False] + matches.extend(child_matches) matches.extend(child.ranking_matches(hide_empty_matches)) @@ -50,6 +54,10 @@ class Round(models.Model): def get_matches_recursive(self, hide_empty_matches): matches = list(self.match_set.all()) # Retrieve matches associated with the current round matches = [m for m in matches if m.should_appear()] + if hide_empty_matches: + matches = [m for m in matches if m.should_appear()] + else: + matches = [m for m in matches if m.disabled is False] # Recursively fetch matches from child rounds for child_round in self.children.all():