From fe7713cb892b64dacc31d18ec24a5d2b317013f2 Mon Sep 17 00:00:00 2001 From: Raz Date: Mon, 24 Mar 2025 11:44:05 +0100 Subject: [PATCH] fix hiding bracket if no bracket --- tournaments/models/tournament.py | 13 +++++++++++++ .../tournaments/navigation_tournament.html | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/tournaments/models/tournament.py b/tournaments/models/tournament.py index 2d6ba1f..b8400fc 100644 --- a/tournaments/models/tournament.py +++ b/tournaments/models/tournament.py @@ -1382,6 +1382,19 @@ class Tournament(models.Model): return serializable_match_groups + def has_bracket(self): + main_rounds = self.round_set.filter( + parent=None, + group_stage_loser_bracket=False + ) + + count = main_rounds.count() + if count == 0: + return False + else: + return True + + class MatchGroup: def __init__(self, name, matches, formatted_schedule, round_id=None): self.name = name diff --git a/tournaments/templates/tournaments/navigation_tournament.html b/tournaments/templates/tournaments/navigation_tournament.html index fd5995f..332d7c9 100644 --- a/tournaments/templates/tournaments/navigation_tournament.html +++ b/tournaments/templates/tournaments/navigation_tournament.html @@ -2,7 +2,7 @@ Informations - {% if tournament.display_matches %} + {% if tournament.display_matches and tournament.has_bracket %} Tableau {% endif %}