diff --git a/tournaments/models/tournament.py b/tournaments/models/tournament.py
index 7bc7535..d8ac5a2 100644
--- a/tournaments/models/tournament.py
+++ b/tournaments/models/tournament.py
@@ -1199,7 +1199,7 @@ class Tournament(models.Model):
if not matches:
return []
- # Get all unfinished matches with court assignments
+ # Get all unfinished matches for courts
active_matches = [
m for m in matches
if m.end_date is None # Not finished
@@ -1215,6 +1215,13 @@ class Tournament(models.Model):
courts.add(match.court_index)
matches_by_court[match.court_index].append(match)
+ # Sort matches within each court by start time
+ for court in matches_by_court:
+ matches_by_court[court].sort(key=lambda m: (
+ m.start_date is None, # None dates come last
+ m.start_date if m.start_date else timezone.now()
+ ))
+
# Sort courts and organize them into groups of 4
sorted_courts = sorted(list(courts))
court_groups = [sorted_courts[i:i+4] for i in range(0, len(sorted_courts), 4)]
@@ -1222,19 +1229,25 @@ class Tournament(models.Model):
ordered_matches = []
# For each group of up to 4 courts
for court_group in court_groups:
- # First row: current/next match for each court
+ # First row: earliest match for each court
for court in court_group:
if court in matches_by_court and matches_by_court[court]:
ordered_matches.append(matches_by_court[court][0])
else:
- ordered_matches.append(None) # Empty space
+ ordered_matches.append({"empty": True})
+ # Pad to 4 courts if needed
+ while len(ordered_matches) % 4 != 0:
+ ordered_matches.append({"empty": True})
# Second row: next match for each court
for court in court_group:
if court in matches_by_court and len(matches_by_court[court]) > 1:
ordered_matches.append(matches_by_court[court][1])
else:
- ordered_matches.append(None) # Empty space
+ ordered_matches.append({"empty": True})
+ # Pad to 4 courts if needed
+ while len(ordered_matches) % 4 != 0:
+ ordered_matches.append({"empty": True})
# Add unassigned matches at the end if needed
unassigned_matches = [
diff --git a/tournaments/static/tournaments/css/style.css b/tournaments/static/tournaments/css/style.css
index 6900b2e..bbb3d49 100644
--- a/tournaments/static/tournaments/css/style.css
+++ b/tournaments/static/tournaments/css/style.css
@@ -816,11 +816,3 @@ h-margin {
.group-stage-link:hover {
color: #f39200; /* Or whatever hover color you prefer */
}
-
-.empty-match-slot {
- height: 100%;
- min-height: 200px; /* adjust as needed */
- background-color: #f5f5f5; /* light grey background */
- border-radius: 8px;
- margin: 10px;
-}
diff --git a/tournaments/templates/tournaments/broadcast/broadcasted_prog.html b/tournaments/templates/tournaments/broadcast/broadcasted_prog.html
index 2b36c3b..5843d59 100644
--- a/tournaments/templates/tournaments/broadcast/broadcasted_prog.html
+++ b/tournaments/templates/tournaments/broadcast/broadcasted_prog.html
@@ -88,12 +88,7 @@
{% include 'tournaments/broadcast/broadcasted_match.html' %}
-
-
-
-
-