|
|
|
@ -19,7 +19,6 @@ class Tournament(models.Model): |
|
|
|
bracket_sort_mode = models.IntegerField(default=0) |
|
|
|
bracket_sort_mode = models.IntegerField(default=0) |
|
|
|
group_stage_count = models.IntegerField(default=0) |
|
|
|
group_stage_count = models.IntegerField(default=0) |
|
|
|
rank_source_date = models.DateTimeField(null=True, blank=True) |
|
|
|
rank_source_date = models.DateTimeField(null=True, blank=True) |
|
|
|
# custom_name = models.CharField(max_length=100, null=True, blank=True) |
|
|
|
|
|
|
|
day_duration = models.IntegerField(default=0) |
|
|
|
day_duration = models.IntegerField(default=0) |
|
|
|
team_count = models.IntegerField(default=0) |
|
|
|
team_count = models.IntegerField(default=0) |
|
|
|
team_sorting = models.IntegerField(default=0) |
|
|
|
team_sorting = models.IntegerField(default=0) |
|
|
|
@ -34,7 +33,6 @@ class Tournament(models.Model): |
|
|
|
prioritize_club_members = models.BooleanField() |
|
|
|
prioritize_club_members = models.BooleanField() |
|
|
|
qualified_per_group_stage = models.IntegerField(default=0) |
|
|
|
qualified_per_group_stage = models.IntegerField(default=0) |
|
|
|
teams_per_group_stage = models.IntegerField(default=0) |
|
|
|
teams_per_group_stage = models.IntegerField(default=0) |
|
|
|
#estimated_end_date = models.DateTimeField(null=True, blank=True) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def __str__(self): |
|
|
|
def __str__(self): |
|
|
|
if self.name: |
|
|
|
if self.name: |
|
|
|
@ -133,6 +131,50 @@ class Tournament(models.Model): |
|
|
|
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()] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def live_matches(self): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
matches = [] |
|
|
|
|
|
|
|
last_started_match = self.last_match() |
|
|
|
|
|
|
|
current_round = last_started_match.round |
|
|
|
|
|
|
|
if current_round: |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
previous_round = self.round_for_index(current_round.index - 1) |
|
|
|
|
|
|
|
if previous_round: |
|
|
|
|
|
|
|
matches.extend(current_round.all_matches()) |
|
|
|
|
|
|
|
matches.extend(previous_round.all_matches()) |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
matches.extend(current_round.all_matches()) |
|
|
|
|
|
|
|
# todo on veut les matchs du round et les poules, comment ça marche ? |
|
|
|
|
|
|
|
# dans le monde idéal on veut afficher plusieurs pages de plusieurs types différents |
|
|
|
|
|
|
|
# est-ce que je construis un json avec des types différents dans un même array ? |
|
|
|
|
|
|
|
# je veux pas que des types différents apparaissent sur une même page |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
matches = self.group_stages_matches() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return matches |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def last_match(self): |
|
|
|
|
|
|
|
matches = [] |
|
|
|
|
|
|
|
for round in self.round_set.all(): |
|
|
|
|
|
|
|
matches.extend(round.match_set.all()) |
|
|
|
|
|
|
|
for group_stage in self.groupstage_set.all(): |
|
|
|
|
|
|
|
matches.extend(group_stage.match_set.all()) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
matches = [m for m in matches if m.start_date] |
|
|
|
|
|
|
|
matches.sort(key=lambda m: -m.start_date) |
|
|
|
|
|
|
|
return matches[0] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def round_for_index(self, index): |
|
|
|
|
|
|
|
return self.round_set.filter(index=index).first() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def group_stages_matches(self): |
|
|
|
|
|
|
|
matches = [] |
|
|
|
|
|
|
|
for group_stage in self.groupstage_set.all(): |
|
|
|
|
|
|
|
matches.extend(group_stage.match_set.all()) |
|
|
|
|
|
|
|
matches = [m for m in matches if m.should_appear()] |
|
|
|
|
|
|
|
matches.sort(key=lambda m: -m.start_date) |
|
|
|
|
|
|
|
return matches |
|
|
|
|
|
|
|
|
|
|
|
class MatchGroup: |
|
|
|
class MatchGroup: |
|
|
|
def __init__(self, name, matches): |
|
|
|
def __init__(self, name, matches): |
|
|
|
self.name = name |
|
|
|
self.name = name |
|
|
|
|