diff --git a/tournaments/models/match.py b/tournaments/models/match.py index 1863e69..b34e676 100644 --- a/tournaments/models/match.py +++ b/tournaments/models/match.py @@ -125,7 +125,8 @@ class Match(models.Model): scores = team_score.scores_array() weight = team_score.team_registration.weight() is_winner = team_score.team_registration.id == self.winning_team_id - team = Team(image, names, scores, weight, is_winner) + walk_out = team_score.walk_out + team = Team(image, names, scores, weight, is_winner, walk_out) livematch.add_team(team) return livematch @@ -147,13 +148,14 @@ class Match(models.Model): # return sort_score class Team: - def __init__(self, image, names, scores, weight, is_winner): + def __init__(self, image, names, scores, weight, is_winner, walk_out): # print(f"image = {image}, names= {names}, scores ={scores}, weight={weight}, win={is_winner}") self.image = image self.names = names self.scores = scores self.weight = weight self.is_winner = is_winner + self.walk_out = walk_out def to_dict(self): return { @@ -162,6 +164,7 @@ class Team: "scores": self.scores, "weight": self.weight, "is_winner": self.is_winner, + "walk_out": self.walk_out, } class LiveMatch: diff --git a/tournaments/models/team_score.py b/tournaments/models/team_score.py index 029061d..3aca93d 100644 --- a/tournaments/models/team_score.py +++ b/tournaments/models/team_score.py @@ -36,9 +36,13 @@ class TeamScore(models.Model): return [] def scores_array(self): - scores = [] if self.score: - scores = [x for x in self.score.split(',')] - if self.walk_out == 1: - scores.insert(0, 'WO') - return scores + 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 e05b52b..3ca6a80 100644 --- a/tournaments/models/tournament.py +++ b/tournaments/models/tournament.py @@ -42,6 +42,12 @@ class Tournament(models.Model): else: return '--' + def display_name(self): + if self.name: + return self.name + else: + return f"{self.level()} {self.category()}" + def level(self): return self.get_federal_level_category_display() diff --git a/tournaments/static/tournaments/css/style.css b/tournaments/static/tournaments/css/style.css index 219041a..f5f5ddd 100644 --- a/tournaments/static/tournaments/css/style.css +++ b/tournaments/static/tournaments/css/style.css @@ -223,7 +223,7 @@ tr { .scores span { width: 30px; /* Fixed width for each score cell */ - text-align: center; /* Center-align the score text */ + text-align: center; } .separator { @@ -237,8 +237,6 @@ tr { vertical-align: middle; text-align: center; padding: 0px 5px; - /* width: 40px; */ - /* justify-content: space-between; */ } .winner { diff --git a/tournaments/templates/tournaments/match_cell.html b/tournaments/templates/tournaments/match_cell.html index 13d4df2..425a3f1 100644 --- a/tournaments/templates/tournaments/match_cell.html +++ b/tournaments/templates/tournaments/match_cell.html @@ -1,72 +1,51 @@ {% load static %} -
-
+
+
- - - - + + + + -
+
- {% for team in match.teams %} + {% for team in match.teams %} -
-
- {% for name in team.names %} -
- {{ name }} -
- {% endfor %} -
-
- {% if match.started %} - {% for score in team.scores %} -
- {{ score }} -
- {% endfor %} - {% else %} - {{ team.weight }} - {% endif %} -
-
- - - - - - {% endfor %} - -
- -
- - - -
- -
+
+
+ {% for name in team.names %} +
+ {{ name }}
+ {% endfor %} +
+ + {% if match.started %} + {% if team.walk_out %} + WO + {% else %} + {% for score in team.scores %} +
+ {{ score }} +
+ {% endfor %} + {% endif %} + {% else %} + {{ team.weight }} + {% endif %} + +
+ + {% endfor %} + +
+ +
+ + + +
+ +
+
diff --git a/tournaments/templates/tournaments/matches.html b/tournaments/templates/tournaments/matches.html index 8e777cd..f01a396 100644 --- a/tournaments/templates/tournaments/matches.html +++ b/tournaments/templates/tournaments/matches.html @@ -2,7 +2,7 @@ {% block head_title %}Matchs{% endblock %} {% block first_title %}{{ tournament.event.display_name }}{% endblock %} -{% block second_title %}{{ tournament.name }}{% endblock %} +{% block second_title %}{{ tournament.display_name }}{% endblock %} {% block content %}