diff --git a/tournaments/templates/tournaments/tournament_bracket.html b/tournaments/templates/tournaments/tournament_bracket.html
index 0eee2fd..a3eeaa0 100644
--- a/tournaments/templates/tournaments/tournament_bracket.html
+++ b/tournaments/templates/tournaments/tournament_bracket.html
@@ -37,6 +37,7 @@ function renderBracket() {
const matchTemplates = document.getElementById('match-templates').children;
const rounds = [];
const matchPositions = [];
+ const matchDisabled = []; // New array to track disabled matches
const doubleButterflyMode = {{ double_butterfly_mode|lower }};
const displayLoserFinal = {{ display_loser_final|lower }};
@@ -121,12 +122,16 @@ function renderBracket() {
roundDiv.appendChild(matchesContainer);
matchPositions[roundIndex] = [];
+ matchDisabled[roundIndex] = []; // Initialize array for this round
roundMatches.forEach((matchTemplate, matchIndex) => {
const matchDiv = document.createElement('div');
matchDiv.className = 'butterfly-match';
matchDiv.style.position = 'absolute';
const isDisabled = matchTemplate.dataset.disabled === 'true';
+ matchDisabled[roundIndex][matchIndex] = isDisabled;
+ let isIncomingLineIsDisabled = isDisabled;
+
let top;
let left;
let right;
@@ -194,6 +199,9 @@ function renderBracket() {
}
if (currentMatchesCount == previousMatchesCount) {
+ if (matchDisabled[roundIndex - 1][matchIndex] == true) {
+ isIncomingLineIsDisabled = true
+ }
top = matchPositions[roundIndex - 1][matchIndex];
} else {
const parentIndex1 = matchIndex * 2;
@@ -266,7 +274,7 @@ function renderBracket() {
}
matchDiv.innerHTML = `
-
+
${matchTemplate.innerHTML}
`;
diff --git a/tournaments/views.py b/tournaments/views.py
index 4120972..e5542ab 100644
--- a/tournaments/views.py
+++ b/tournaments/views.py
@@ -1008,6 +1008,43 @@ def get_bracket(tournament, parent_round=None, double_butterfly_mode=False, disp
# Add first half of each round (from last to semi-finals)
for round in main_rounds:
matches = round.match_set.filter(disabled=False).order_by('index')
+ next_round = main_rounds.filter(index=round.index - 1).first()
+ if next_round:
+ next_round_matches = next_round.match_set.filter(disabled=False).order_by('index')
+ else:
+ next_round_matches = []
+
+ if len(matches) < len(next_round_matches):
+ all_matches = round.match_set.order_by('index')
+ filtered_matches = []
+
+ # Process matches in pairs
+ i = 0
+ while i < len(all_matches):
+ # Get the current match and its pair (if available)
+ current_match = all_matches[i]
+ pair_match = all_matches[i+1] if i+1 < len(all_matches) else None
+
+ # Only filter out the pair if both matches are disabled
+ if current_match.disabled and pair_match and pair_match.disabled:
+ # Skip one of the matches in the pair
+ filtered_matches.append(current_match)
+ pass
+ else:
+ # Keep the current match
+ if current_match.disabled == False:
+ filtered_matches.append(current_match)
+ # If there's a pair match, keep it too
+ if pair_match and pair_match.disabled == False:
+ filtered_matches.append(pair_match)
+
+ # Move to the next pair
+ i += 2
+
+ # Replace the matches list with our filtered list
+ matches = filtered_matches
+
+
if matches:
if len(matches) > 1 and double_butterfly_mode:
@@ -1035,6 +1072,42 @@ def get_bracket(tournament, parent_round=None, double_butterfly_mode=False, disp
if double_butterfly_mode:
for round in main_rounds_reversed:
matches = round.match_set.filter(disabled=False).order_by('index')
+ next_round = main_rounds_reversed.filter(index=round.index - 1).first()
+ if next_round:
+ next_round_matches = next_round.match_set.filter(disabled=False).order_by('index')
+ else:
+ next_round_matches = []
+
+ if len(matches) < len(next_round_matches):
+ all_matches = round.match_set.order_by('index')
+ filtered_matches = []
+
+ # Process matches in pairs
+ i = 0
+ while i < len(all_matches):
+ # Get the current match and its pair (if available)
+ current_match = all_matches[i]
+ pair_match = all_matches[i+1] if i+1 < len(all_matches) else None
+
+ # Only filter out the pair if both matches are disabled
+ if current_match.disabled and pair_match and pair_match.disabled:
+ # Skip one of the matches in the pair
+ filtered_matches.append(current_match)
+ pass
+ else:
+ # Keep the current match
+ if current_match.disabled == False:
+ filtered_matches.append(current_match)
+ # If there's a pair match, keep it too
+ if pair_match and pair_match.disabled == False:
+ filtered_matches.append(pair_match)
+
+ # Move to the next pair
+ i += 2
+
+ # Replace the matches list with our filtered list
+ matches = filtered_matches
+
if matches:
if len(matches) > 1:
midpoint = int(len(matches) / 2)