fix pbl stuff

shop
Raz 8 months ago
parent c69f7385f9
commit 194a7c8ba3
  1. 2
      tournaments/models/group_stage.py
  2. 36
      tournaments/models/match.py
  3. 12
      tournaments/models/team_registration.py
  4. 17
      tournaments/models/tournament.py
  5. 54
      tournaments/static/tournaments/css/broadcast.css
  6. 37
      tournaments/static/tournaments/css/style.css
  7. 13
      tournaments/templates/tournaments/broadcast/broadcasted_group_stage.html
  8. 10
      tournaments/templates/tournaments/broadcast/broadcasted_match.html
  9. 4
      tournaments/templates/tournaments/group_stage_cell.html
  10. 6
      tournaments/templates/tournaments/match_cell.html

@ -135,7 +135,7 @@ class GroupStage(models.Model):
def has_at_least_one_started_match(self): def has_at_least_one_started_match(self):
for match in self.match_set.all(): for match in self.match_set.all():
if match.start_date is not None and match.start_date <= timezone.now(): if match.start_date is not None and match.start_date <= timezone.now() and match.confirmed is True:
return True return True
return False return False

@ -180,37 +180,45 @@ class Match(models.Model):
if len(team_scores) == 0: if len(team_scores) == 0:
if (self.round and self.round.parent is None and self.round.tournament.round_set.filter(parent__isnull=True, group_stage_loser_bracket=False).count() - 1 == self.round.index): if (self.round and self.round.parent is None and self.round.tournament.round_set.filter(parent__isnull=True, group_stage_loser_bracket=False).count() - 1 == self.round.index):
names = ["Qualifié", ''] names = ["Qualifié"]
team = self.default_live_team(names) team = self.default_live_team(names)
teams.append(team) teams.append(team)
names = ["Qualifié", ''] names = ["Qualifié"]
team = self.default_live_team(names) team = self.default_live_team(names)
teams.append(team) teams.append(team)
return teams return teams
if (self.group_stage): if (self.group_stage):
names = ["Équipe de poule", ''] names = ["Équipe de poule"]
team = self.default_live_team(names) team = self.default_live_team(names)
teams.append(team) teams.append(team)
names = ["Équipe de poule", ''] names = ["Équipe de poule"]
team = self.default_live_team(names) team = self.default_live_team(names)
teams.append(team) teams.append(team)
return teams return teams
elif self.round and self.round.parent: elif self.round and self.round.parent:
if loser_top_match: if loser_top_match:
names = [f"Perdant {loser_top_match.computed_name()}", ''] names = [f"Perdant {loser_top_match.computed_name()}"]
team = self.default_live_team(names) team = self.default_live_team(names)
teams.append(team) teams.append(team)
if loser_bottom_match: if loser_bottom_match:
names = [f"Perdant {loser_bottom_match.computed_name()}", ''] names = [f"Perdant {loser_bottom_match.computed_name()}"]
team = self.default_live_team(names)
teams.append(team)
if previous_top_match:
names = [f"Gagnant {previous_top_match.computed_name()}"]
team = self.default_live_team(names)
teams.append(team)
if previous_bottom_match:
names = [f"Gagnant {previous_bottom_match.computed_name()}"]
team = self.default_live_team(names) team = self.default_live_team(names)
teams.append(team) teams.append(team)
elif self.round and self.round.parent is None: elif self.round and self.round.parent is None:
if previous_top_match: if previous_top_match:
names = [f"Gagnant {previous_top_match.computed_name()}", ''] names = [f"Gagnant {previous_top_match.computed_name()}"]
team = self.default_live_team(names) team = self.default_live_team(names)
teams.append(team) teams.append(team)
if previous_bottom_match: if previous_bottom_match:
names = [f"Gagnant {previous_bottom_match.computed_name()}", ''] names = [f"Gagnant {previous_bottom_match.computed_name()}"]
team = self.default_live_team(names) team = self.default_live_team(names)
teams.append(team) teams.append(team)
elif len(team_scores) == 1: elif len(team_scores) == 1:
@ -218,33 +226,33 @@ class Match(models.Model):
existing_team = team_scores[0].live_team(self) existing_team = team_scores[0].live_team(self)
if (self.group_stage): if (self.group_stage):
teams.append(existing_team) teams.append(existing_team)
names = ["Équipe de poule", ''] names = ["Équipe de poule"]
team = self.default_live_team(names) team = self.default_live_team(names)
teams.append(team) teams.append(team)
elif self.round: elif self.round:
if loser_top_match and loser_top_match.disabled == False and loser_top_match.end_date is None: if loser_top_match and loser_top_match.disabled == False and loser_top_match.end_date is None:
names = [f"Perdant {loser_top_match.computed_name()}", ''] names = [f"Perdant {loser_top_match.computed_name()}"]
team = self.default_live_team(names) team = self.default_live_team(names)
teams.append(team) teams.append(team)
teams.append(existing_team) teams.append(existing_team)
elif loser_bottom_match: elif loser_bottom_match:
names = [f"Perdant {loser_bottom_match.computed_name()}", ''] names = [f"Perdant {loser_bottom_match.computed_name()}"]
team = self.default_live_team(names) team = self.default_live_team(names)
teams.append(existing_team) teams.append(existing_team)
teams.append(team) teams.append(team)
elif previous_top_match and previous_top_match.disabled == False and previous_top_match.end_date is None: elif previous_top_match and previous_top_match.disabled == False and previous_top_match.end_date is None:
names = [f"Gagnant {previous_top_match.computed_name()}", ''] names = [f"Gagnant {previous_top_match.computed_name()}"]
team = self.default_live_team(names) team = self.default_live_team(names)
teams.append(team) teams.append(team)
teams.append(existing_team) teams.append(existing_team)
elif previous_bottom_match: elif previous_bottom_match:
names = [f"Gagnant {previous_bottom_match.computed_name()}", ''] names = [f"Gagnant {previous_bottom_match.computed_name()}"]
team = self.default_live_team(names) team = self.default_live_team(names)
teams.append(existing_team) teams.append(existing_team)
teams.append(team) teams.append(team)
elif (self.round.parent is None and self.round.tournament.round_set.filter(parent__isnull=True, group_stage_loser_bracket=False).count() - 1 == self.round.index): elif (self.round.parent is None and self.round.tournament.round_set.filter(parent__isnull=True, group_stage_loser_bracket=False).count() - 1 == self.round.index):
match_index_within_round = self.index - (int(2 ** self.round.index) - 1) match_index_within_round = self.index - (int(2 ** self.round.index) - 1)
names = ["Qualifié", ''] names = ["Qualifié"]
team = self.default_live_team(names) team = self.default_live_team(names)
if match_index_within_round < int(2 ** self.round.index) / 2: if match_index_within_round < int(2 ** self.round.index) / 2:
teams.append(existing_team) teams.append(existing_team)

@ -40,27 +40,27 @@ class TeamRegistration(models.Model):
def player_names_as_list(self): def player_names_as_list(self):
players = list(self.playerregistration_set.all()) players = list(self.playerregistration_set.all())
if len(players) == 0: if len(players) == 0:
return ['', ''] return []
elif len(players) == 1: elif len(players) == 1:
return [players[0].name(), ''] return [players[0].name()]
else: else:
return [pr.name() for pr in players] return [pr.name() for pr in players]
def team_names(self): def team_names(self):
if self.name: if self.name:
return [self.name, ''] #add an empty line if it's a team name return [self.name] #add an empty line if it's a team name
else: else:
return self.player_names_as_list() return self.player_names_as_list()
def shortened_team_names(self): def shortened_team_names(self):
if self.name: if self.name:
return [self.name, ''] #add an empty line if it's a team name return [self.name] #add an empty line if it's a team name
else: else:
players = list(self.playerregistration_set.all()) players = list(self.playerregistration_set.all())
if len(players) == 0: if len(players) == 0:
return ['', ''] return []
elif len(players) == 1: elif len(players) == 1:
return [players[0].shortened_name(), ''] return [players[0].shortened_name()]
else: else:
return [pr.shortened_name() for pr in players] return [pr.shortened_name() for pr in players]

@ -678,6 +678,12 @@ class Tournament(models.Model):
if previous_round: if previous_round:
# print('previous_round') # print('previous_round')
matches.extend(previous_round.get_matches_recursive(True)) matches.extend(previous_round.get_matches_recursive(True))
previous_previous_round = self.round_for_index(current_round.index + 2)
if previous_previous_round:
previous_previous_matches = previous_previous_round.get_matches_recursive(True)
previous_previous_matches = [m for m in previous_previous_matches if m.end_date is None]
matches.extend(previous_previous_matches)
else: else:
# print('group_stages') # print('group_stages')
group_stages = [gs.live_group_stages() for gs in self.last_group_stage_step()] group_stages = [gs.live_group_stages() for gs in self.last_group_stage_step()]
@ -786,7 +792,16 @@ class Tournament(models.Model):
group_stages.sort(key=lambda gs: (gs.index, gs.start_date is None, gs.start_date)) group_stages.sort(key=lambda gs: (gs.index, gs.start_date is None, gs.start_date))
for group_stage in group_stages: for group_stage in group_stages:
matches.extend(group_stage.match_set.all()) matches.extend(group_stage.match_set.all())
matches = [m for m in matches if m.should_appear()]
if len(matches) > 16:
# if more than 16 groupstage matches
now = timezone.now()
future_threshold = now + timedelta(hours=1)
past_threshold = now - timedelta(hours=1)
matches = [m for m in matches if m.should_appear() and
(m.start_date is None or m.start_date <= future_threshold) and # Not starting in more than 1h
(m.end_date is None or m.end_date >= past_threshold)] # Not finished for more than 1h
matches = matches[:16]
matches.sort(key=lambda m: (m.start_date is None, m.end_date is not None, m.start_date, m.index)) matches.sort(key=lambda m: (m.start_date is None, m.end_date is not None, m.start_date, m.index))
group_stage_loser_bracket = list(self.round_set.filter(parent=None, group_stage_loser_bracket=True).all()) group_stage_loser_bracket = list(self.round_set.filter(parent=None, group_stage_loser_bracket=True).all())

@ -25,3 +25,57 @@ body {
.bold { .bold {
font-family: "Montserrat-Bold"; font-family: "Montserrat-Bold";
} }
.player {
position: relative;
flex: 1;
display: flex;
flex-direction: column;
min-height: 2.8em; /* This ensures minimum height for 2 lines */
justify-content: center;
overflow: hidden;
}
/* Add this if you want empty lines to take up space */
.player div {
min-height: 1.4em; /* Height for single line */
}
/* For single player teams */
.player.single-player .bold {
max-height: 2.8em; /* Adjust based on your needs */
line-height: 1.4em;
overflow: hidden;
position: relative;
text-overflow: ellipsis;
}
/* For two player teams */
.player.two-players .bold {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.flex {
display: flex;
align-items: center;
}
.flex-left {
flex: 1;
text-align: left;
justify-content: center;
min-height: 4em;
padding-right: 5px;
}
.flex-right {
flex: initial;
text-align: right;
justify-content: center;
}
.center {
align-items: center;
}

@ -323,9 +323,34 @@ tr {
} }
.player { .player {
position: relative;
flex: 1; flex: 1;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
min-height: 2.8em; /* This ensures minimum height for 2 lines */
justify-content: center;
overflow: hidden;
}
/* Add this if you want empty lines to take up space */
.player div {
min-height: 1.4em; /* Height for single line */
}
/* For single player teams */
.player.single-player .semibold {
max-height: 2.8em; /* Adjust based on your needs */
line-height: 1.4em;
overflow: hidden;
position: relative;
text-overflow: ellipsis;
}
/* For two player teams */
.player.two-players .semibold {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
} }
.scores { .scores {
@ -344,7 +369,6 @@ tr {
font-size: 1.3em; font-size: 1.3em;
vertical-align: middle; vertical-align: middle;
text-align: center; text-align: center;
padding: 0px 5px;
/* width: 30px; */ /* width: 30px; */
} }
@ -718,14 +742,15 @@ h-margin {
.flex-left { .flex-left {
flex: 1; flex: 1;
text-align: left; text-align: left;
padding: 5px 0px; justify-content: center;
min-height: 4em;
padding-right: 5px;
} }
.flex-right { .flex-right {
flex: initial; flex: initial;
text-align: right; text-align: right;
vertical-align: middle; justify-content: center;
padding: 5px 0px;
} }
#header { #header {
@ -838,10 +863,6 @@ h-margin {
background-color: #90ee90; /* Light green color */ background-color: #90ee90; /* Light green color */
} }
.player {
position: relative; /* Ensures the overlay is positioned within this block */
}
.overlay-text { .overlay-text {
position: absolute; position: absolute;
top: 50%; top: 50%;

@ -8,7 +8,10 @@
<div> <div>
<div class="flex" :class="group_stage.teams[i-1].qualified ? 'qualified' : ''"> <div class="flex" :class="group_stage.teams[i-1].qualified ? 'qualified' : ''">
<div class="flex-left"> <div class="flex-left player" :class="{
'single-player': group_stage.teams[i-1].names.length === 1,
'two-players': group_stage.teams[i-1].names.length === 2
}">
<template x-for="name in group_stage.teams[i-1].names"> <template x-for="name in group_stage.teams[i-1].names">
<div class="bold" x-text="name"></div> <div class="bold" x-text="name"></div>
@ -30,18 +33,16 @@
</div> </div>
<div class="flex-right"> <div class="flex-right">
<div x-show="group_stage.teams[i-1].match_count == 0"> <div x-show="group_stage.started === true">
<div class="score ws numbers" x-show="hide_weight == false"> <div class="score ws numbers" x-show="hide_weight === false">
<span x-text="group_stage.teams[i-1].weight"></span> <span x-text="group_stage.teams[i-1].weight"></span>
</div> </div>
</div> </div>
<div x-show="group_stage.teams[i-1].match_count > 0"> <div x-show="group_stage.teams[i-1].match_count > 0 and group_stage.started === false">
<div class="center">
<div class="score ws numbers"><span x-text="group_stage.teams[i-1].win_loss"></span></div> <div class="score ws numbers"><span x-text="group_stage.teams[i-1].win_loss"></span></div>
<div class="ws numbers"><span x-text="group_stage.teams[i-1].diff"></span></div> <div class="ws numbers"><span x-text="group_stage.teams[i-1].diff"></span></div>
</div> </div>
</div>
</div> </div>
</div> </div>

@ -16,7 +16,10 @@
<div> <div>
<div class="match-result"> <div class="match-result">
<div class="player"> <div class="player" :class="{
'single-player': match.teams[i-1].names.length === 1,
'two-players': match.teams[i-1].names.length === 2
}">
<!-- Show lucky loser or walkout status --> <!-- Show lucky loser or walkout status -->
<template x-if="match.teams[i-1].is_lucky_loser"> <template x-if="match.teams[i-1].is_lucky_loser">
<div class="overlay-text right-label minor-info semibold">(LL)</div> <div class="overlay-text right-label minor-info semibold">(LL)</div>
@ -65,6 +68,11 @@
}, },
}" x-html="showWalkOut(match, match.teams[i-1])"> }" x-html="showWalkOut(match, match.teams[i-1])">
</span> </span>
<template x-if="!match.tournament?.hide_weight && match.teams[i-1].weight && !match.has_walk_out && match.teams[i-1].scores.length === 0">
<span class="score ws numbers" x-text="match.teams[i-1].weight"></span>
</template>
</div> </div>
</div> </div>

@ -13,7 +13,7 @@
{% for team in group_stage.teams %} {% for team in group_stage.teams %}
<div class="flex {% if team.qualified %}qualified{% endif %}"> <div class="flex {% if team.qualified %}qualified{% endif %}">
<div class="flex-left"> <div class="flex-left player {% if team.names|length == 1 %}single-player{% else %}two-players{% endif %}">
{% if team.team_registration.id %} {% if team.team_registration.id %}
<a href="{% url 'team-details' tournament.id team.team_registration.id %}" class="group-stage-link"> <!-- Add this anchor tag --> <a href="{% url 'team-details' tournament.id team.team_registration.id %}" class="group-stage-link"> <!-- Add this anchor tag -->
{% endif %} {% endif %}
@ -31,10 +31,8 @@
</div> </div>
<div class="flex-right"> <div class="flex-right">
{% if group_stage.started %} {% if group_stage.started %}
<div class="center">
<div class="score ws numbers">{{ team.wins_losses }}</div> <div class="score ws numbers">{{ team.wins_losses }}</div>
<div class="ws numbers">{{ team.formatted_diff }}</div> <div class="ws numbers">{{ team.formatted_diff }}</div>
</div>
{% else %} {% else %}
{% if tournament.hide_weight %} {% if tournament.hide_weight %}
<div class="score ws"></div> <div class="score ws"></div>

@ -14,7 +14,7 @@
{% for team in match.teams %} {% for team in match.teams %}
<div class="match-result {% cycle 'bottom-border' '' %}"> <div class="match-result {% cycle 'bottom-border' '' %}">
<div class="player"> <div class="player {% if team.names|length == 1 %}single-player{% else %}two-players{% endif %}">
{% if team.id %} {% if team.id %}
<a href="{% url 'team-details' tournament.id team.id %}" class="player-link"> <a href="{% url 'team-details' tournament.id team.id %}" class="player-link">
{% endif %} {% endif %}
@ -27,11 +27,7 @@
{% for name in team.names %} {% for name in team.names %}
<div class="semibold{% if team.walk_out == 1 %} strikethrough{% endif %}{% 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 %}
{{ name }} {{ name }}
{% else %}
&nbsp;
{% endif %}
</div> </div>
{% endfor %} {% endfor %}
{% if team.id %} {% if team.id %}

Loading…
Cancel
Save