|
|
|
|
@ -1953,21 +1953,26 @@ class Tournament(BaseModel): |
|
|
|
|
- days: List of unique days found (datetime.date objects) |
|
|
|
|
- match_groups: Dictionary of match groups by date and hour or just for the selected day |
|
|
|
|
""" |
|
|
|
|
event = self.event |
|
|
|
|
tournaments_count = 1 |
|
|
|
|
if event: |
|
|
|
|
tournaments_count = event.tournaments.count() |
|
|
|
|
|
|
|
|
|
if event_mode is True and self.event.tournaments.count() == 1: |
|
|
|
|
if event_mode is True and tournaments_count == 1: |
|
|
|
|
event_mode = False |
|
|
|
|
|
|
|
|
|
if self.event.tournaments.count() == 1: |
|
|
|
|
show_teams_in_prog = False |
|
|
|
|
if tournaments_count == 1: |
|
|
|
|
show_teams_in_prog = self.show_teams_in_prog |
|
|
|
|
else: |
|
|
|
|
show_teams_in_prog = self.event.tournaments.filter(show_teams_in_prog=True).first() is not None |
|
|
|
|
elif event: |
|
|
|
|
show_teams_in_prog = event.tournaments.filter(show_teams_in_prog=True).first() is not None |
|
|
|
|
|
|
|
|
|
# Get all matches from rounds and group stages - use a set to avoid duplicates |
|
|
|
|
all_matches = set() |
|
|
|
|
|
|
|
|
|
tournaments = [self] |
|
|
|
|
if event_mode is True: |
|
|
|
|
tournaments = self.event.tournaments.all() |
|
|
|
|
if event_mode is True and event: |
|
|
|
|
tournaments = event.tournaments.all() |
|
|
|
|
|
|
|
|
|
# Check if all tournaments have started - if so, always show teams |
|
|
|
|
all_started = True |
|
|
|
|
@ -2016,6 +2021,44 @@ class Tournament(BaseModel): |
|
|
|
|
sorted_days = sorted(list(days)) |
|
|
|
|
# Create match groups for the selected day |
|
|
|
|
match_groups = [] |
|
|
|
|
hide_teams = show_teams_in_prog == False |
|
|
|
|
# When broadcast=True, handle all days with matches |
|
|
|
|
if broadcast: |
|
|
|
|
today = timezone.now().replace(hour=0, minute=0, second=0, microsecond=0).date() |
|
|
|
|
sorted_days = [day for day in sorted(list(days)) if day >= today] |
|
|
|
|
|
|
|
|
|
# Process all days with matches |
|
|
|
|
for selected_day in sorted_days: |
|
|
|
|
|
|
|
|
|
# Group matches by hour |
|
|
|
|
matches_by_hour = {} |
|
|
|
|
for match in matches_by_day[selected_day]: |
|
|
|
|
local_time = timezone.localtime(match.planned_start_date) |
|
|
|
|
hour_key = local_time.strftime('%H:%M') |
|
|
|
|
|
|
|
|
|
if hour_key not in matches_by_hour: |
|
|
|
|
matches_by_hour[hour_key] = [] |
|
|
|
|
|
|
|
|
|
matches_by_hour[hour_key].append(match) |
|
|
|
|
|
|
|
|
|
# Create match groups for each hour |
|
|
|
|
for hour, matches in sorted(matches_by_hour.items()): |
|
|
|
|
# Sort matches by court if available |
|
|
|
|
matches.sort(key=lambda m: (m.court_index if m.court_index is not None else 999)) |
|
|
|
|
|
|
|
|
|
local_date = matches[0].local_planned_start_date() |
|
|
|
|
formatted_name = formats.date_format(local_date, format='l j F à H:i').capitalize() |
|
|
|
|
mg = self.create_match_group( |
|
|
|
|
name=formatted_name, |
|
|
|
|
matches=matches, |
|
|
|
|
round_id=None, |
|
|
|
|
round_index=None, |
|
|
|
|
hide_teams=hide_teams, |
|
|
|
|
event_mode=event_mode, |
|
|
|
|
broadcast=broadcast |
|
|
|
|
) |
|
|
|
|
match_groups.append(mg) |
|
|
|
|
return sorted_days, match_groups |
|
|
|
|
|
|
|
|
|
if all or day is None: |
|
|
|
|
today = timezone.now().replace(hour=0, minute=0, second=0, microsecond=0).date() |
|
|
|
|
@ -2039,7 +2082,6 @@ class Tournament(BaseModel): |
|
|
|
|
|
|
|
|
|
matches_by_hour[hour_key].append(match) |
|
|
|
|
|
|
|
|
|
hide_teams = show_teams_in_prog == False |
|
|
|
|
# Create match groups for each hour |
|
|
|
|
for hour, matches in sorted(matches_by_hour.items()): |
|
|
|
|
# Sort matches by court if available |
|
|
|
|
@ -2084,7 +2126,6 @@ class Tournament(BaseModel): |
|
|
|
|
|
|
|
|
|
matches_by_hour[hour_key].append(match) |
|
|
|
|
|
|
|
|
|
hide_teams = show_teams_in_prog == False |
|
|
|
|
# Create match groups for each hour |
|
|
|
|
for hour, matches in sorted(matches_by_hour.items()): |
|
|
|
|
# Sort matches by court if available |
|
|
|
|
|