|
|
|
|
@ -1984,38 +1984,48 @@ class Tournament(BaseModel): |
|
|
|
|
sorted_days = sorted(list(days)) |
|
|
|
|
# Create match groups for the selected day |
|
|
|
|
match_groups = [] |
|
|
|
|
print(days) |
|
|
|
|
|
|
|
|
|
if all: |
|
|
|
|
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) |
|
|
|
|
|
|
|
|
|
hide_teams = self.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 |
|
|
|
|
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) |
|
|
|
|
today = timezone.now().date() |
|
|
|
|
if today not in days: |
|
|
|
|
selected_day = sorted_days[0] if sorted_days else None |
|
|
|
|
else: |
|
|
|
|
# Default to first day if today is not in the list |
|
|
|
|
if self.has_ended(): |
|
|
|
|
selected_day = sorted_days[-1] |
|
|
|
|
else: |
|
|
|
|
selected_day = sorted_days[0] |
|
|
|
|
|
|
|
|
|
# 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) |
|
|
|
|
|
|
|
|
|
hide_teams = self.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 |
|
|
|
|
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 specific day requested, filter to that day |
|
|
|
|
|