diff --git a/tournaments/models/tournament.py b/tournaments/models/tournament.py index cc9d175..7bc7535 100644 --- a/tournaments/models/tournament.py +++ b/tournaments/models/tournament.py @@ -1192,6 +1192,61 @@ class Tournament(models.Model): self._being_deleted = True super().delete(*args, **kwargs) + def broadcasted_prog(self): + # Get matches from broadcasted_matches_and_group_stages + matches, _ = self.broadcasted_matches_and_group_stages() + + if not matches: + return [] + + # Get all unfinished matches with court assignments + active_matches = [ + m for m in matches + if m.end_date is None # Not finished + and m.court_index is not None + ] + + # Group matches by court + matches_by_court = {} + courts = set() + for match in active_matches: + if match.court_index not in matches_by_court: + matches_by_court[match.court_index] = [] + courts.add(match.court_index) + matches_by_court[match.court_index].append(match) + + # 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)] + + ordered_matches = [] + # For each group of up to 4 courts + for court_group in court_groups: + # First row: current/next 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 + + # 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 + + # Add unassigned matches at the end if needed + unassigned_matches = [ + m for m in matches + if m.end_date is None and m.court_index is None + ] + if unassigned_matches: + ordered_matches.extend(unassigned_matches) + + return ordered_matches + + class MatchGroup: def __init__(self, name, matches, formatted_schedule): self.name = name diff --git a/tournaments/static/tournaments/css/style.css b/tournaments/static/tournaments/css/style.css index bbb3d49..6900b2e 100644 --- a/tournaments/static/tournaments/css/style.css +++ b/tournaments/static/tournaments/css/style.css @@ -816,3 +816,11 @@ 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/broadcast.html b/tournaments/templates/tournaments/broadcast/broadcast.html index 0828677..61b7dea 100644 --- a/tournaments/templates/tournaments/broadcast/broadcast.html +++ b/tournaments/templates/tournaments/broadcast/broadcast.html @@ -12,6 +12,7 @@
+