add prog view in broadcast

bracket-feature
Raz 10 months ago
parent c5baa3a797
commit c8c58ce4ec
  1. 21
      tournaments/models/tournament.py
  2. 8
      tournaments/static/tournaments/css/style.css
  3. 5
      tournaments/templates/tournaments/broadcast/broadcasted_prog.html

@ -1199,7 +1199,7 @@ class Tournament(models.Model):
if not matches: if not matches:
return [] return []
# Get all unfinished matches with court assignments # Get all unfinished matches for courts
active_matches = [ active_matches = [
m for m in matches m for m in matches
if m.end_date is None # Not finished if m.end_date is None # Not finished
@ -1215,6 +1215,13 @@ class Tournament(models.Model):
courts.add(match.court_index) courts.add(match.court_index)
matches_by_court[match.court_index].append(match) 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 # Sort courts and organize them into groups of 4
sorted_courts = sorted(list(courts)) sorted_courts = sorted(list(courts))
court_groups = [sorted_courts[i:i+4] for i in range(0, len(sorted_courts), 4)] 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 = [] ordered_matches = []
# For each group of up to 4 courts # For each group of up to 4 courts
for court_group in court_groups: 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: for court in court_group:
if court in matches_by_court and matches_by_court[court]: if court in matches_by_court and matches_by_court[court]:
ordered_matches.append(matches_by_court[court][0]) ordered_matches.append(matches_by_court[court][0])
else: 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 # Second row: next match for each court
for court in court_group: for court in court_group:
if court in matches_by_court and len(matches_by_court[court]) > 1: if court in matches_by_court and len(matches_by_court[court]) > 1:
ordered_matches.append(matches_by_court[court][1]) ordered_matches.append(matches_by_court[court][1])
else: 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 # Add unassigned matches at the end if needed
unassigned_matches = [ unassigned_matches = [

@ -816,11 +816,3 @@ h-margin {
.group-stage-link:hover { .group-stage-link:hover {
color: #f39200; /* Or whatever hover color you prefer */ 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;
}

@ -88,12 +88,7 @@
<template x-if="!match.empty"> <template x-if="!match.empty">
{% include 'tournaments/broadcast/broadcasted_match.html' %} {% include 'tournaments/broadcast/broadcasted_match.html' %}
</template> </template>
<template x-if="match.empty">
<div class="empty-match-slot"></div>
</template>
</div> </div>
</template> </template>
</template> </template>

Loading…
Cancel
Save