clubs
Laurent 2 years ago
parent ccd1e2fc74
commit 4cf08b6509
  1. 22
      tournaments/models/group_stage.py
  2. 2
      tournaments/models/team_registration.py
  3. 4
      tournaments/templates/tournaments/broadcasted_group_stages.html

@ -28,6 +28,16 @@ class GroupStage(models.Model):
def live_group_stages(self): def live_group_stages(self):
lgs = LiveGroupStage(self.name()) lgs = LiveGroupStage(self.name())
gs_teams = {} gs_teams = {}
# init all teams
for team_registration in self.teamregistration_set.all():
if team_registration in gs_teams:
team = gs_teams[team_registration]
else:
team = GroupStageTeam(team_registration)
gs_teams[team_registration] = team
# compute matches
for match in self.match_set.all(): for match in self.match_set.all():
lgs.add_match(match) lgs.add_match(match)
team_scores = match.team_scores.all() team_scores = match.team_scores.all()
@ -37,14 +47,10 @@ class GroupStage(models.Model):
team_registration = team_score.team_registration team_registration = team_score.team_registration
if team_registration in gs_teams: if team_registration in gs_teams:
team = gs_teams[team_registration] team = gs_teams[team_registration]
else: if match.winning_team_id == team_registration.id:
team = GroupStageTeam(team_registration) team.wins += 1
gs_teams[team_registration] = team else:
team.losses += 1
if match.winning_team_id == team_registration.id:
team.wins += 1
else:
team.losses += 1
ts1 = team_scores[0] ts1 = team_scores[0]
ts2 = team_scores[1] ts2 = team_scores[1]

@ -40,7 +40,7 @@ class TeamRegistration(models.Model):
matches = [m for m in all_matches if m.end_date is None] matches = [m for m in all_matches if m.end_date is None]
if matches: if matches:
return matches[0] return matches[0]
else: elif all_matches:
return all_matches[0] return all_matches[0]
def next_stage(self): def next_stage(self):

@ -71,7 +71,7 @@
<div class="dark_bubble"> <div class="dark_bubble">
<div class="flex-row"> <div class="flex-row">
<label class="left-label matchtitle white"><span x-text="group_stage.title"></span></label> <label class="left-label matchtitle winner"><span x-text="group_stage.title"></span></label>
<!-- <label class="right-label info"><span x-text="group_stage.date"></span></label> --> <!-- <label class="right-label info"><span x-text="group_stage.date"></span></label> -->
</div> </div>
@ -103,7 +103,7 @@
</div> </div>
</div> </div>
<div x-show="i === 1"> <div x-show="i != group_stage.teams.length">
<div class="bottom-border"></div> <div class="bottom-border"></div>
</div> </div>

Loading…
Cancel
Save