fix attempt on summons with same match

clubs
Laurent 2 years ago
parent 14cb9abe65
commit 144d444a7b
  1. 2
      tournaments/models/team_registration.py
  2. 12
      tournaments/models/tournament.py

@ -37,7 +37,7 @@ class TeamRegistration(models.Model):
return "no players"
def next_match(self):
all_matches = map(lambda ts: ts.match, self.teamscore_set.all())
all_matches = [ts.match for ts in self.teamscore_set.all()]
all_matches = sorted(all_matches, key=lambda m: m.start_date)
matches = [m for m in all_matches if m.end_date is None]
if matches:

@ -54,18 +54,18 @@ class Tournament(models.Model):
return self.start_date.strftime("%d/%m/%y")
def team_summons(self):
summons = []
for team_registration in self.teamregistration_set.all():
next_match = team_registration.next_match()
if next_match:
match = None
match = team_registration.next_match()
if match:
names = team_registration.team_names()
stage = next_match.stage_name()
stage = match.stage_name()
weight = team_registration.weight()
summon = TeamSummon(names, next_match.start_date, weight, stage, team_registration.logo)
summon = TeamSummon(names, match.start_date, weight, stage, team_registration.logo)
summons.append(summon)
summons.sort(key=lambda s: s.weight)
summons.sort(key=lambda s: s.weight)
return summons
def live_matches(self, broadcasted):

Loading…
Cancel
Save