|
|
|
@ -53,6 +53,9 @@ class Tournament(models.Model): |
|
|
|
def formatted_start_date(self): |
|
|
|
def formatted_start_date(self): |
|
|
|
return self.start_date.strftime("%d/%m/%y") |
|
|
|
return self.start_date.strftime("%d/%m/%y") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def in_progress(self): |
|
|
|
|
|
|
|
return self.end_date is None |
|
|
|
|
|
|
|
|
|
|
|
def team_summons(self): |
|
|
|
def team_summons(self): |
|
|
|
summons = [] |
|
|
|
summons = [] |
|
|
|
for team_registration in self.teamregistration_set.all(): |
|
|
|
for team_registration in self.teamregistration_set.all(): |
|
|
|
@ -67,14 +70,15 @@ class Tournament(models.Model): |
|
|
|
summons.sort(key=lambda s: s.weight) |
|
|
|
summons.sort(key=lambda s: s.weight) |
|
|
|
return summons |
|
|
|
return summons |
|
|
|
|
|
|
|
|
|
|
|
def live_matches(self, broadcasted): |
|
|
|
def live_matches(self, broadcasted, group_stage_id, round_id): |
|
|
|
|
|
|
|
|
|
|
|
matches = [] |
|
|
|
matches = [] |
|
|
|
for group_stage in self.groupstage_set.all(): |
|
|
|
if group_stage_id: |
|
|
|
for match in group_stage.match_set.all(): |
|
|
|
matches = self.group_stage_matches(group_stage_id) |
|
|
|
matches.append(match) |
|
|
|
elif round_id: |
|
|
|
for round in self.round_set.all(): |
|
|
|
matches = self.round_matches(round_id) |
|
|
|
for match in round.match_set.all(): |
|
|
|
else: |
|
|
|
matches.append(match) |
|
|
|
matches = self.all_matches() |
|
|
|
|
|
|
|
|
|
|
|
matches = [m for m in matches if m.broadcasted==True] |
|
|
|
matches = [m for m in matches if m.broadcasted==True] |
|
|
|
if not broadcasted: |
|
|
|
if not broadcasted: |
|
|
|
@ -85,6 +89,26 @@ class Tournament(models.Model): |
|
|
|
return [match.live_match() for match in matches] |
|
|
|
return [match.live_match() for match in matches] |
|
|
|
# return map(lambda match: match.live_match(), matches) |
|
|
|
# return map(lambda match: match.live_match(), matches) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def all_matches(self): |
|
|
|
|
|
|
|
matches = [] |
|
|
|
|
|
|
|
for group_stage in self.groupstage_set.all(): |
|
|
|
|
|
|
|
for match in group_stage.match_set.all(): |
|
|
|
|
|
|
|
matches.append(match) |
|
|
|
|
|
|
|
for round in self.round_set.all(): |
|
|
|
|
|
|
|
for match in round.match_set.all(): |
|
|
|
|
|
|
|
matches.append(match) |
|
|
|
|
|
|
|
return matches |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def group_stage_matches(self, group_stage_id): |
|
|
|
|
|
|
|
group_stage = self.groupstage_set.filter(id=group_stage_id).first() |
|
|
|
|
|
|
|
print(group_stage.name()) |
|
|
|
|
|
|
|
print(len(group_stage.match_set.all())) |
|
|
|
|
|
|
|
return group_stage.match_set.all() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def round_matches(self, round_id): |
|
|
|
|
|
|
|
round = self.round_set.filter(id=round_id).first() |
|
|
|
|
|
|
|
return round.match_set.all() |
|
|
|
|
|
|
|
|
|
|
|
def live_group_stages(self): |
|
|
|
def live_group_stages(self): |
|
|
|
return [gs.live_group_stages() for gs in self.groupstage_set.all()] |
|
|
|
return [gs.live_group_stages() for gs in self.groupstage_set.all()] |
|
|
|
# return map(lambda gs: gs.live_group_stages(), self.groupstage_set.all()) |
|
|
|
# return map(lambda gs: gs.live_group_stages(), self.groupstage_set.all()) |
|
|
|
|