From 995ea0e08b4b26a1c4051961cace50e84b1eb145 Mon Sep 17 00:00:00 2001 From: Razmig Sarkissian Date: Fri, 28 Feb 2025 11:00:07 +0100 Subject: [PATCH] fix lucky loser stuff --- tournaments/models/match.py | 20 +++++++++++++------ tournaments/models/team_registration.py | 2 +- tournaments/models/team_score.py | 3 ++- tournaments/static/tournaments/css/style.css | 15 +++++++------- .../broadcast/broadcasted_match.html | 20 ++++++++++++++++--- .../templates/tournaments/match_cell.html | 18 +++++++++++------ .../templates/tournaments/player_row.html | 16 +++++++-------- .../templates/tournaments/team_stats.html | 14 ++++++------- 8 files changed, 69 insertions(+), 39 deletions(-) diff --git a/tournaments/models/match.py b/tournaments/models/match.py index 17d29a8..b10e051 100644 --- a/tournaments/models/match.py +++ b/tournaments/models/match.py @@ -134,7 +134,7 @@ class Match(models.Model): is_winner = False scores = [] walk_out = None - team = Team(None, image, names, scores, weight, is_winner, walk_out) + team = Team(None, image, names, scores, weight, is_winner, walk_out, False) return team def is_ready(self): @@ -188,9 +188,11 @@ class Match(models.Model): teams.append(team) else: teams.append(existing_team) - else: + elif len(team_scores) == 2: # Both team scores present teams.extend([team_score.live_team(self) for team_score in team_scores]) + else: + teams.extend([team_score.live_team(self) for team_score in team_scores if team_score.walk_out != 1]) return teams @@ -353,7 +355,7 @@ class Match(models.Model): # return sort_score class Team: - def __init__(self, id, image, names, scores, weight, is_winner, walk_out): + 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) self.image = image @@ -361,7 +363,11 @@ class Team: self.scores = scores self.weight = weight self.is_winner = is_winner - self.walk_out = walk_out is not None + self.walk_out = walk_out + self.is_lucky_loser = is_lucky_loser + + def is_walk_out(self): + return self.walk_out is not None def to_dict(self): return { @@ -371,6 +377,8 @@ class Team: "weight": self.weight, "is_winner": self.is_winner, "walk_out": self.walk_out, + "is_walk_out": self.is_walk_out(), + "is_lucky_loser": self.is_lucky_loser } class LiveMatch: @@ -388,7 +396,7 @@ class LiveMatch: def add_team(self, team): self.teams.append(team) - if team.walk_out is True: + if team.is_walk_out() is True: self.has_walk_out = True def to_dict(self): @@ -407,7 +415,7 @@ class LiveMatch: def show_time_indication(self): for team in self.teams: - if team.walk_out and len(team.scores) == 0: + if team.is_walk_out() and len(team.scores) == 0: return False return True diff --git a/tournaments/models/team_registration.py b/tournaments/models/team_registration.py index 2bc141a..cac26a0 100644 --- a/tournaments/models/team_registration.py +++ b/tournaments/models/team_registration.py @@ -225,7 +225,7 @@ class TeamRegistration(models.Model): if team_rank > self.final_ranking: sign = "+" if team_rank == self.final_ranking: - sign = "" + sign = "+" return f" ({sign}"+f"{abs(self.final_ranking - team_rank)})" def get_points_earned(self): diff --git a/tournaments/models/team_score.py b/tournaments/models/team_score.py index e23c225..9e22b12 100644 --- a/tournaments/models/team_score.py +++ b/tournaments/models/team_score.py @@ -98,5 +98,6 @@ class TeamScore(models.Model): scores = self.parsed_scores() walk_out = self.walk_out from .match import Team # Import Team only when needed - team = Team(id, image, names, scores, weight, is_winner, walk_out) + is_lucky_loser = self.lucky_loser is not None + team = Team(id, image, names, scores, weight, is_winner, walk_out, is_lucky_loser) return team diff --git a/tournaments/static/tournaments/css/style.css b/tournaments/static/tournaments/css/style.css index a112a8b..e220038 100644 --- a/tournaments/static/tournaments/css/style.css +++ b/tournaments/static/tournaments/css/style.css @@ -326,7 +326,6 @@ tr { flex: 1; display: flex; flex-direction: column; - /* Stack player names vertically */ } .scores { @@ -803,12 +802,6 @@ h-margin { color: #707070; } -.single-line { - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; -} - .group-stage-link { text-decoration: none; color: inherit; @@ -826,3 +819,11 @@ h-margin { .tournament-info a:hover { color: #f39200; } + +.top-border { + border-top: 1px solid #ccc; +} + +.strikethrough { + text-decoration: line-through; +} diff --git a/tournaments/templates/tournaments/broadcast/broadcasted_match.html b/tournaments/templates/tournaments/broadcast/broadcasted_match.html index 9e3d0cc..b3efe0a 100644 --- a/tournaments/templates/tournaments/broadcast/broadcasted_match.html +++ b/tournaments/templates/tournaments/broadcast/broadcasted_match.html @@ -17,14 +17,27 @@
+ + + +
{% endif %} + + {% if team.is_lucky_loser %} +
Repêché
+ {% elif team.walk_out == 1 %} +
Forfait
+ {% endif %} {% for name in team.names %} -
+
{% if name|length > 0 %} {{ name }} {% else %} @@ -32,7 +38,11 @@ {% endif %}
- {% if match.should_show_scores %} + {% if match.has_walk_out %} + + {% if team.is_walk_out %}WO{% endif %} + + {% elif match.should_show_scores %}
{% for score in team.scores %} @@ -43,10 +53,6 @@ {% endfor %}
- {% elif match.has_walk_out %} - - {% if team.walk_out %}WO{% endif %} - {% elif not tournament.hide_weight and team.weight %} {{ team.weight }} {% endif %} diff --git a/tournaments/templates/tournaments/player_row.html b/tournaments/templates/tournaments/player_row.html index 6a0a374..34775fe 100644 --- a/tournaments/templates/tournaments/player_row.html +++ b/tournaments/templates/tournaments/player_row.html @@ -3,15 +3,13 @@
-
+
-
{{ player.clean_club_name }} -
-
+
Classement @@ -22,7 +20,8 @@
-
+ {% if player.calculate_age %} +
Age @@ -30,14 +29,15 @@
- {{ player.calculate_age|default:"?" }} ans + {{ player.calculate_age }} ans
+ {% endif %} {% if player.points %} -
+
Points @@ -50,7 +50,7 @@ {% endif %} {% if player.tournament_played %} -
+
Tournois joués diff --git a/tournaments/templates/tournaments/team_stats.html b/tournaments/templates/tournaments/team_stats.html index e1a7d47..ea4d88e 100644 --- a/tournaments/templates/tournaments/team_stats.html +++ b/tournaments/templates/tournaments/team_stats.html @@ -5,7 +5,7 @@
{% with stats=team.get_statistics %} -
+
Poids de la paire @@ -16,7 +16,7 @@
-
+
Position initiale @@ -29,7 +29,7 @@ {% if stats.final_ranking %} -
+
Classement final @@ -42,7 +42,7 @@ {% endif %} {% if stats.points_earned %} -
+
Points gagnés @@ -55,7 +55,7 @@ {% endif %} {% if stats.initial_stage %} -
+
Départ @@ -67,7 +67,7 @@
{% endif %} -
+
Matchs joués @@ -79,7 +79,7 @@
{% if stats.victory_ratio %} -
+
Ratio victoires