fix event hide team mode

apikeys
Razmig Sarkissian 5 months ago
parent 1f2514b903
commit a9a5fc87fb
  1. 18
      tournaments/models/tournament.py

@ -1950,6 +1950,11 @@ class Tournament(BaseModel):
if event_mode is True and self.event.tournaments.count() == 1: if event_mode is True and self.event.tournaments.count() == 1:
event_mode = False event_mode = False
if self.event.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
# Get all matches from rounds and group stages - use a set to avoid duplicates # Get all matches from rounds and group stages - use a set to avoid duplicates
all_matches = set() all_matches = set()
@ -1957,6 +1962,15 @@ class Tournament(BaseModel):
if event_mode is True: if event_mode is True:
tournaments = self.event.tournaments.all() tournaments = self.event.tournaments.all()
# Check if all tournaments have started - if so, always show teams
all_started = True
for t in tournaments:
if not t.has_started():
all_started = False
break
if all_started:
show_teams_in_prog = True
for tournament in tournaments: for tournament in tournaments:
# Get matches only from top-level rounds to avoid duplicates # Get matches only from top-level rounds to avoid duplicates
for round in tournament.rounds.filter(parent=None).all(): for round in tournament.rounds.filter(parent=None).all():
@ -2018,7 +2032,7 @@ class Tournament(BaseModel):
matches_by_hour[hour_key].append(match) matches_by_hour[hour_key].append(match)
hide_teams = self.show_teams_in_prog == False hide_teams = show_teams_in_prog == False
# Create match groups for each hour # Create match groups for each hour
for hour, matches in sorted(matches_by_hour.items()): for hour, matches in sorted(matches_by_hour.items()):
# Sort matches by court if available # Sort matches by court if available
@ -2063,7 +2077,7 @@ class Tournament(BaseModel):
matches_by_hour[hour_key].append(match) matches_by_hour[hour_key].append(match)
hide_teams = self.show_teams_in_prog == False hide_teams = show_teams_in_prog == False
# Create match groups for each hour # Create match groups for each hour
for hour, matches in sorted(matches_by_hour.items()): for hour, matches in sorted(matches_by_hour.items()):
# Sort matches by court if available # Sort matches by court if available

Loading…
Cancel
Save