diff --git a/tournaments/models/match.py b/tournaments/models/match.py
index 24aa950..1995428 100644
--- a/tournaments/models/match.py
+++ b/tournaments/models/match.py
@@ -204,6 +204,7 @@ class Match(models.Model):
names = [f"Perdant {loser_bottom_match.computed_name()}", '']
team = self.default_live_team(names)
teams.append(team)
+ elif self.round and self.round.parent is None:
if previous_top_match:
names = [f"Gagnant {previous_top_match.computed_name()}", '']
team = self.default_live_team(names)
diff --git a/tournaments/templates/tournaments/bracket_match_cell.html b/tournaments/templates/tournaments/bracket_match_cell.html
new file mode 100644
index 0000000..578c1fd
--- /dev/null
+++ b/tournaments/templates/tournaments/bracket_match_cell.html
@@ -0,0 +1,80 @@
+{% load static %}
+
+
+
+
+
+
+ {% if not match.ended %}
+
+ {% endif %}
+
+
+
+
+ {% for team in match.teams %}
+
+
+
+ {% if match.has_walk_out %}
+
+ {% if team.is_walk_out %}WO{% endif %}
+
+ {% elif match.should_show_scores %}
+
+ {% for score in team.scores %}
+
+ {{ score.main }}
+ {% if score.tiebreak %}
+ {{ score.tiebreak }}
+ {% endif %}
+
+ {% endfor %}
+
+ {% elif not tournament.hide_weight and team.weight %}
+
{{ team.weight }}
+ {% endif %}
+
+
+ {% endfor %}
+
+
+
+
+
+
+
+
+
+
diff --git a/tournaments/templates/tournaments/tournament_bracket.html b/tournaments/templates/tournaments/tournament_bracket.html
index 7e72d08..aec5256 100644
--- a/tournaments/templates/tournaments/tournament_bracket.html
+++ b/tournaments/templates/tournaments/tournament_bracket.html
@@ -19,7 +19,7 @@
data-match-index="{{ forloop.counter0 }}"
data-disabled="{{ match.disabled|lower }}"
class="match-template">
- {% include 'tournaments/match_cell.html' %}
+ {% include 'tournaments/bracket_match_cell.html' %}
{% endfor %}
{% endif %}
@@ -58,6 +58,7 @@ function renderBracket() {
rounds.forEach((roundMatches, roundIndex) => {
const roundDiv = document.createElement('div');
roundDiv.className = 'butterfly-round';
+ roundDiv.style.setProperty('--match-width', `${360}px`);
matchPositions[roundIndex] = [];
roundMatches.forEach((matchTemplate, matchIndex) => {
@@ -91,7 +92,11 @@ function renderBracket() {
top = matchPositions[roundIndex - 2][matchIndex];
nextMatchDistance = 0;
} else if (roundIndex == finalRoundIndex) {
- top = matchPositions[roundIndex - 3][1 + matchIndex];
+ if (finalRoundIndex === 2) {
+ top = matchPositions[0][matchIndex];
+ } else {
+ top = matchPositions[0][1 + matchIndex];
+ }
nextMatchDistance = baseDistance;
} else if (currentRoundMatches > previousRoundMatches) {
// Bracket is reversed - matches are splitting instead of combining
@@ -116,17 +121,19 @@ function renderBracket() {
}
if (roundIndex >= finalRoundIndex - 1) {
+ if (roundCount > 5) {
matchDiv.style.transform = `translateX(-50%)`;
if (roundIndex >= finalRoundIndex + 2) {
matchDiv.style.transform = `translateX(-100%)`;
}
if (roundIndex == finalRoundIndex - 1) {
- matchDiv.classList.add('inward');
- }
- if (roundIndex == finalRoundIndex + 1) {
- matchDiv.classList.add('outward');
- }
+ matchDiv.classList.add('inward');
+ }
+ if (roundIndex == finalRoundIndex + 1) {
+ matchDiv.classList.add('outward');
+ }
+ }
}
@@ -146,7 +153,9 @@ function renderBracket() {
const matchDiv2 = document.createElement('div');
matchDiv2.className = 'butterfly-match';
matchDiv2.style.position = 'absolute';
- matchDiv2.style.transform = `translateX(-50%)`;
+ if (roundCount > 5) {
+ matchDiv2.style.transform = `translateX(-50%)`;
+ }
matchDiv2.classList.add('inward');
matchDiv2.classList.add('semi-final');
matchDiv2.style.setProperty('--next-match-distance', `${baseDistance}px`);
@@ -191,7 +200,7 @@ function renderBracket() {
.butterfly-round {
position: relative;
- width: 25%; /* 300px for match + 20px on each side for lines */
+ width: var(--match-width); /* 300px for match + 20px on each side for lines */
flex-shrink: 0; /* Prevents rounds from shrinking */
}
diff --git a/tournaments/views.py b/tournaments/views.py
index a45096d..db54de4 100644
--- a/tournaments/views.py
+++ b/tournaments/views.py
@@ -965,7 +965,6 @@ def tournament_bracket(request, tournament_id):
parent=None,
group_stage_loser_bracket=False
).order_by('-index')
-
main_rounds_reversed = tournament.round_set.filter(
parent=None,
group_stage_loser_bracket=False
@@ -989,8 +988,8 @@ def tournament_bracket(request, tournament_id):
matches = round.match_set.all()
if matches:
- midpoint = len(matches) // 2
if len(matches) > 1:
+ midpoint = int(len(matches) / 2)
first_half_matches = matches[:midpoint]
else:
first_half_matches = list(matches) # Convert QuerySet to a list
@@ -1011,8 +1010,8 @@ def tournament_bracket(request, tournament_id):
for round in main_rounds_reversed:
matches = round.match_set.all()
if matches:
- midpoint = len(matches) // 2
if len(matches) > 1:
+ midpoint = int(len(matches) / 2)
first_half_matches = matches[midpoint:]
match_group = tournament.create_match_group(
@@ -1021,7 +1020,6 @@ def tournament_bracket(request, tournament_id):
)
serializable_match_groups.append(match_group)
-
context = {
'tournament': tournament,
'match_groups': serializable_match_groups