fix lucky loser stuff

bracket-feature^2
Razmig Sarkissian 8 months ago
parent f3fa3e0e9c
commit 995ea0e08b
  1. 20
      tournaments/models/match.py
  2. 2
      tournaments/models/team_registration.py
  3. 3
      tournaments/models/team_score.py
  4. 15
      tournaments/static/tournaments/css/style.css
  5. 20
      tournaments/templates/tournaments/broadcast/broadcasted_match.html
  6. 18
      tournaments/templates/tournaments/match_cell.html
  7. 16
      tournaments/templates/tournaments/player_row.html
  8. 14
      tournaments/templates/tournaments/team_stats.html

@ -134,7 +134,7 @@ class Match(models.Model):
is_winner = False is_winner = False
scores = [] scores = []
walk_out = None 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 return team
def is_ready(self): def is_ready(self):
@ -188,9 +188,11 @@ class Match(models.Model):
teams.append(team) teams.append(team)
else: else:
teams.append(existing_team) teams.append(existing_team)
else: elif len(team_scores) == 2:
# Both team scores present # Both team scores present
teams.extend([team_score.live_team(self) for team_score in team_scores]) 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 return teams
@ -353,7 +355,7 @@ class Match(models.Model):
# return sort_score # return sort_score
class Team: 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}") # print(f"image = {image}, names= {names}, scores ={scores}, weight={weight}, win={is_winner}")
self.id = str(id) self.id = str(id)
self.image = image self.image = image
@ -361,7 +363,11 @@ class Team:
self.scores = scores self.scores = scores
self.weight = weight self.weight = weight
self.is_winner = is_winner 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): def to_dict(self):
return { return {
@ -371,6 +377,8 @@ class Team:
"weight": self.weight, "weight": self.weight,
"is_winner": self.is_winner, "is_winner": self.is_winner,
"walk_out": self.walk_out, "walk_out": self.walk_out,
"is_walk_out": self.is_walk_out(),
"is_lucky_loser": self.is_lucky_loser
} }
class LiveMatch: class LiveMatch:
@ -388,7 +396,7 @@ class LiveMatch:
def add_team(self, team): def add_team(self, team):
self.teams.append(team) self.teams.append(team)
if team.walk_out is True: if team.is_walk_out() is True:
self.has_walk_out = True self.has_walk_out = True
def to_dict(self): def to_dict(self):
@ -407,7 +415,7 @@ class LiveMatch:
def show_time_indication(self): def show_time_indication(self):
for team in self.teams: 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 False
return True return True

@ -225,7 +225,7 @@ class TeamRegistration(models.Model):
if team_rank > self.final_ranking: if team_rank > self.final_ranking:
sign = "+" sign = "+"
if team_rank == self.final_ranking: if team_rank == self.final_ranking:
sign = "" sign = "+"
return f" ({sign}"+f"{abs(self.final_ranking - team_rank)})" return f" ({sign}"+f"{abs(self.final_ranking - team_rank)})"
def get_points_earned(self): def get_points_earned(self):

@ -98,5 +98,6 @@ class TeamScore(models.Model):
scores = self.parsed_scores() scores = self.parsed_scores()
walk_out = self.walk_out walk_out = self.walk_out
from .match import Team # Import Team only when needed 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 return team

@ -326,7 +326,6 @@ tr {
flex: 1; flex: 1;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
/* Stack player names vertically */
} }
.scores { .scores {
@ -803,12 +802,6 @@ h-margin {
color: #707070; color: #707070;
} }
.single-line {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.group-stage-link { .group-stage-link {
text-decoration: none; text-decoration: none;
color: inherit; color: inherit;
@ -826,3 +819,11 @@ h-margin {
.tournament-info a:hover { .tournament-info a:hover {
color: #f39200; color: #f39200;
} }
.top-border {
border-top: 1px solid #ccc;
}
.strikethrough {
text-decoration: line-through;
}

@ -17,14 +17,27 @@
<div class="match-result"> <div class="match-result">
<div class="player bold"> <div class="player bold">
<!-- Show lucky loser or walkout status -->
<template x-if="match.teams[i-1].is_lucky_loser">
<div class="small">Repêché</div>
</template>
<template x-if="match.teams[i-1].walk_out === 1">
<div class="small">Forfait</div>
</template>
<template x-for="name in match.teams[i-1].names"> <template x-for="name in match.teams[i-1].names">
<div :class="match.teams[i-1].is_winner ? 'winner' : ''"> <div :class="{
<span x-text="name === '' ? '\u00A0' : name"></span> 'semibold': true,
'strikethrough': match.teams[i-1].walk_out === 1,
'winner': match.teams[i-1].is_winner
}">
<span x-text="name === '' ? ' ' : name"></span>
</div> </div>
</template> </template>
</div> </div>
<div class="scores"> <div class="scores">
<template x-for="score in match.teams[i-1].scores"> <template x-for="score in match.teams[i-1].scores">
<template x-if="match.has_walk_out === false ">
<span class="score ws" <span class="score ws"
:class="{ :class="{
'w35px': score.tiebreak, 'w35px': score.tiebreak,
@ -37,6 +50,7 @@
<sup x-text="score.tiebreak"></sup> <sup x-text="score.tiebreak"></sup>
</template> </template>
</span> </span>
</template>
</template> </template>
<span x-data="{ <span x-data="{
@ -44,7 +58,7 @@
let html = `` let html = ``
if (match.has_walk_out) { if (match.has_walk_out) {
html += `<span class='score bold w60px'>` html += `<span class='score bold w60px'>`
if (team.walk_out) html += `WO` if (team.walk_out == 0) html += `WO`
html += `</span>` html += `</span>`
} }
return html return html

@ -18,8 +18,14 @@
{% if team.id %} {% if team.id %}
<a href="{% url 'team-details' tournament.id team.id %}" class="player-link"> <!-- Add this anchor tag --> <a href="{% url 'team-details' tournament.id team.id %}" class="player-link"> <!-- Add this anchor tag -->
{% endif %} {% endif %}
{% if team.is_lucky_loser %}
<div class="small">Repêché</div>
{% elif team.walk_out == 1 %}
<div class="small">Forfait</div>
{% endif %}
{% for name in team.names %} {% for name in team.names %}
<div class="semibold {% if team.is_winner %}winner{% endif %}"> <div class="semibold{% if team.walk_out == 1 %} strikethrough{% endif %}{% if team.is_winner %} winner{% endif %}">
{% if name|length > 0 %} {% if name|length > 0 %}
{{ name }} {{ name }}
{% else %} {% else %}
@ -32,7 +38,11 @@
{% endif %} {% endif %}
</div> </div>
{% if match.should_show_scores %} {% if match.has_walk_out %}
<span class="score ws w60px">
{% if team.is_walk_out %}WO{% endif %}
</span>
{% elif match.should_show_scores %}
<div class="scores"> <div class="scores">
{% for score in team.scores %} {% for score in team.scores %}
<span class="score ws {% if score.tiebreak %}w35px{% else %}w30px{% endif %}{% if team.is_winner %} winner{% endif %}"> <span class="score ws {% if score.tiebreak %}w35px{% else %}w30px{% endif %}{% if team.is_winner %} winner{% endif %}">
@ -43,10 +53,6 @@
</span> </span>
{% endfor %} {% endfor %}
</div> </div>
{% elif match.has_walk_out %}
<span class="score ws w60px">
{% if team.walk_out %}WO{% endif %}
</span>
{% elif not tournament.hide_weight and team.weight %} {% elif not tournament.hide_weight and team.weight %}
<span class="score ws numbers">{{ team.weight }}</span> <span class="score ws numbers">{{ team.weight }}</span>
{% endif %} {% endif %}

@ -3,15 +3,13 @@
<label class="matchtitle">{{ player.name }}</label> <label class="matchtitle">{{ player.name }}</label>
<div> <div>
<div class="match-result bottom-border" style="padding-right: 10px;"> <div class="match-result" style="padding-right: 10px;">
<div class="player"> <div class="player">
<div class="single-line">
<strong>{{ player.clean_club_name }}</strong> <strong>{{ player.clean_club_name }}</strong>
</div>
</div> </div>
</div> </div>
<div class="match-result bottom-border"> <div class="match-result top-border">
<div class="player"> <div class="player">
<div class="semibold"> <div class="semibold">
<strong>Classement</strong> <strong>Classement</strong>
@ -22,7 +20,8 @@
</div> </div>
</div> </div>
<div class="match-result bottom-border"> {% if player.calculate_age %}
<div class="match-result top-border">
<div class="player"> <div class="player">
<div class="semibold"> <div class="semibold">
<strong>Age</strong> <strong>Age</strong>
@ -30,14 +29,15 @@
</div> </div>
<div class="scores"> <div class="scores">
<span class="score ws numbers"> <span class="score ws numbers">
{{ player.calculate_age|default:"?" }} ans {{ player.calculate_age }} ans
</span> </span>
</div> </div>
</div> </div>
{% endif %}
{% if player.points %} {% if player.points %}
<div class="match-result bottom-border"> <div class="match-result top-border">
<div class="player"> <div class="player">
<div class="semibold"> <div class="semibold">
<strong>Points</strong> <strong>Points</strong>
@ -50,7 +50,7 @@
{% endif %} {% endif %}
{% if player.tournament_played %} {% if player.tournament_played %}
<div class="match-result"> <div class="match-result top-border">
<div class="player"> <div class="player">
<div class="semibold"> <div class="semibold">
<strong>Tournois joués</strong> <strong>Tournois joués</strong>

@ -5,7 +5,7 @@
<div> <div>
{% with stats=team.get_statistics %} {% with stats=team.get_statistics %}
<div class="match-result bottom-border"> <div class="match-result">
<div class="player"> <div class="player">
<div class="semibold"> <div class="semibold">
<strong>Poids de la paire</strong> <strong>Poids de la paire</strong>
@ -16,7 +16,7 @@
</div> </div>
</div> </div>
<div class="match-result bottom-border"> <div class="match-result top-border">
<div class="player"> <div class="player">
<div class="semibold"> <div class="semibold">
<strong>Position initiale</strong> <strong>Position initiale</strong>
@ -29,7 +29,7 @@
{% if stats.final_ranking %} {% if stats.final_ranking %}
<div class="match-result bottom-border"> <div class="match-result top-border">
<div class="player"> <div class="player">
<div class="semibold"> <div class="semibold">
<strong>Classement final</strong> <strong>Classement final</strong>
@ -42,7 +42,7 @@
{% endif %} {% endif %}
{% if stats.points_earned %} {% if stats.points_earned %}
<div class="match-result bottom-border"> <div class="match-result top-border">
<div class="player"> <div class="player">
<div class="semibold"> <div class="semibold">
<strong>Points gagnés</strong> <strong>Points gagnés</strong>
@ -55,7 +55,7 @@
{% endif %} {% endif %}
{% if stats.initial_stage %} {% if stats.initial_stage %}
<div class="match-result bottom-border"> <div class="match-result top-border">
<div class="player"> <div class="player">
<div class="semibold"> <div class="semibold">
<strong>Départ</strong> <strong>Départ</strong>
@ -67,7 +67,7 @@
</div> </div>
{% endif %} {% endif %}
<div class="match-result bottom-border"> <div class="match-result top-border">
<div class="player"> <div class="player">
<div class="semibold"> <div class="semibold">
<strong>Matchs joués</strong> <strong>Matchs joués</strong>
@ -79,7 +79,7 @@
</div> </div>
{% if stats.victory_ratio %} {% if stats.victory_ratio %}
<div class="match-result"> <div class="match-result top-border">
<div class="player"> <div class="player">
<div class="semibold"> <div class="semibold">
<strong>Ratio victoires</strong> <strong>Ratio victoires</strong>

Loading…
Cancel
Save