|
|
|
@ -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] |
|
|
|
|