From 58286464d0249184455b14d238a1e153f7ad0618 Mon Sep 17 00:00:00 2001 From: Laurent Date: Wed, 24 Apr 2024 10:45:31 +0200 Subject: [PATCH] Improves WO layout --- static/tournaments/css/style.css | 9 +++++++++ tournaments/models/match.py | 15 ++++++++++++++- tournaments/models/team_score.py | 8 +------- tournaments/models/tournament.py | 2 +- tournaments/static/tournaments/css/style.css | 9 +++++++++ tournaments/templates/tournaments/match_cell.html | 15 +++++++++++---- 6 files changed, 45 insertions(+), 13 deletions(-) diff --git a/static/tournaments/css/style.css b/static/tournaments/css/style.css index d6bd29d..b9204a7 100644 --- a/static/tournaments/css/style.css +++ b/static/tournaments/css/style.css @@ -426,6 +426,15 @@ tr { width: 100%; } +.w40px { + width: 40px; +} +.w60px { + width: 60px; +} +.w70px { + width: 70px; +} .w80px { width: 80px; } diff --git a/tournaments/models/match.py b/tournaments/models/match.py index b34e676..e96cf34 100644 --- a/tournaments/models/match.py +++ b/tournaments/models/match.py @@ -20,7 +20,8 @@ class Match(models.Model): broadcasted = models.BooleanField(default=False) def __str__(self): - return " / ".join(self.player_names()) + names = " / ".join(self.player_names()) + return f"{self.stage_name()}: {names}" # player_names = " / ".join(self.player_names()) # if self.round: @@ -188,3 +189,15 @@ class LiveMatch: "court": self.court, "started": self.started, } + + def has_walk_out(self): + for team in self.teams: + if team.walk_out: + return True + return False + + def show_duration(self): + for team in self.teams: + if team.walk_out and len(team.scores) == 0: + return False + return True diff --git a/tournaments/models/team_score.py b/tournaments/models/team_score.py index 3aca93d..5eaa6c9 100644 --- a/tournaments/models/team_score.py +++ b/tournaments/models/team_score.py @@ -8,7 +8,7 @@ class TeamScore(models.Model): team_registration = models.ForeignKey(TeamRegistration, on_delete=models.CASCADE, null=True, blank=True) player_registrations = models.ManyToManyField(PlayerRegistration, blank=True) score = models.CharField(max_length=50, null=True, blank=True) - walk_out = models.IntegerField(null=True, blank=True) #id, int of the walked_out team + walk_out = models.IntegerField(null=True, blank=True) # TODO type of WO: forfeit, injury... lucky_loser = models.BooleanField() def __str__(self): @@ -40,9 +40,3 @@ class TeamScore(models.Model): return [x for x in self.score.split(',')] else: return [] - # scores = [] - # if self.score: - # scores = [x for x in self.score.split(',')] - # if self.walk_out == 1: - # scores.insert(0, 'WO') - # return scores diff --git a/tournaments/models/tournament.py b/tournaments/models/tournament.py index 0dbf9cb..b8c0bb7 100644 --- a/tournaments/models/tournament.py +++ b/tournaments/models/tournament.py @@ -90,7 +90,7 @@ class Tournament(models.Model): def all_groups(self, broadcasted): groups = [] - for round in self.round_set.all(): + for round in self.round_set.all().order_by('index'): groups.extend(self.round_match_groups(round, broadcasted, hide_empty_matches=True)) for group_stage in self.groupstage_set.all(): group = self.group_stage_match_group(group_stage, broadcasted, hide_empty_matches=True) diff --git a/tournaments/static/tournaments/css/style.css b/tournaments/static/tournaments/css/style.css index f5f5ddd..4aca219 100644 --- a/tournaments/static/tournaments/css/style.css +++ b/tournaments/static/tournaments/css/style.css @@ -473,6 +473,15 @@ tr { .w20px { width: 20px; } +.w40px { + width: 40px; +} +.w60px { + width: 60px; +} +.w70px { + width: 7px; +} .w80px { width: 80px; } diff --git a/tournaments/templates/tournaments/match_cell.html b/tournaments/templates/tournaments/match_cell.html index 425a3f1..95a5e1d 100644 --- a/tournaments/templates/tournaments/match_cell.html +++ b/tournaments/templates/tournaments/match_cell.html @@ -22,15 +22,18 @@ {% if match.started %} - {% if team.walk_out %} - WO - {% else %} {% for score in team.scores %}
{{ score }}
{% endfor %} + + {% if match.has_walk_out %} + + {% if team.walk_out %}WO{% endif %} + {% endif %} + {% else %} {{ team.weight }} {% endif %} @@ -42,7 +45,11 @@
- +