From 60dd2ca335b22ef5f22c8500bc2d9fcaa2bffc18 Mon Sep 17 00:00:00 2001 From: Razmig Sarkissian Date: Tue, 11 Mar 2025 18:23:46 +0100 Subject: [PATCH] fix bracket --- tournaments/models/match.py | 8 +- tournaments/models/tournament.py | 7 +- tournaments/static/tournaments/css/style.css | 1 - .../tournaments/tournament_bracket.html | 105 +++++++++++++----- tournaments/urls.py | 1 + tournaments/views.py | 89 ++++++++++----- 6 files changed, 148 insertions(+), 63 deletions(-) diff --git a/tournaments/models/match.py b/tournaments/models/match.py index e69aa67..a555531 100644 --- a/tournaments/models/match.py +++ b/tournaments/models/match.py @@ -430,7 +430,10 @@ class Match(models.Model): class Team: def __init__(self, id, image, names, scores, weight, is_winner, walk_out, is_lucky_loser): # print(f"image = {image}, names= {names}, scores ={scores}, weight={weight}, win={is_winner}") - self.id = str(id) + if id is not None: + self.id = str(id) + else: + self.id = None self.image = image self.names = names self.scores = scores @@ -451,7 +454,8 @@ class Team: "is_winner": self.is_winner, "walk_out": self.walk_out, "is_walk_out": self.is_walk_out(), - "is_lucky_loser": self.is_lucky_loser + "is_lucky_loser": self.is_lucky_loser, + "id": self.id } class LiveMatch: diff --git a/tournaments/models/tournament.py b/tournaments/models/tournament.py index f54e50b..5574cc5 100644 --- a/tournaments/models/tournament.py +++ b/tournaments/models/tournament.py @@ -534,7 +534,7 @@ class Tournament(models.Model): return groups - def create_match_group(self, name, matches): + def create_match_group(self, name, matches, round_id=None): matches = list(matches) live_matches = [match.live_match() for match in matches] # Filter out matches that have a start_date of None @@ -551,7 +551,7 @@ class Tournament(models.Model): time_format = 'l d M' formatted_schedule = f" - {formats.date_format(local_start, format=time_format)}" - return MatchGroup(name, live_matches, formatted_schedule) + return MatchGroup(name, live_matches, formatted_schedule, round_id) def live_group_stages(self): group_stages = self.get_computed_group_stage() @@ -1330,10 +1330,11 @@ class Tournament(models.Model): class MatchGroup: - def __init__(self, name, matches, formatted_schedule): + def __init__(self, name, matches, formatted_schedule, round_id=None): self.name = name self.matches = matches self.formatted_schedule = formatted_schedule + self.round_id = round_id def add_match(self, match): self.matches.append(match) diff --git a/tournaments/static/tournaments/css/style.css b/tournaments/static/tournaments/css/style.css index 43d788a..c7a7bd2 100644 --- a/tournaments/static/tournaments/css/style.css +++ b/tournaments/static/tournaments/css/style.css @@ -818,7 +818,6 @@ h-margin { text-decoration: none; color: inherit; display: block; - padding: 2px 8px; border-radius: 6px; } diff --git a/tournaments/templates/tournaments/tournament_bracket.html b/tournaments/templates/tournaments/tournament_bracket.html index 9db28d2..0eee2fd 100644 --- a/tournaments/templates/tournaments/tournament_bracket.html +++ b/tournaments/templates/tournaments/tournament_bracket.html @@ -20,6 +20,7 @@ data-disabled="{{ match.disabled|lower }}" data-match-group-name="{{ match_group.name }}" data-match-format="{{ match.format }}" + data-round-id="{{ match_group.round_id }}" class="match-template"> {% include 'tournaments/bracket_match_cell.html' %} @@ -29,13 +30,15 @@