|
|
|
@ -260,6 +260,56 @@ class Tournament(models.Model): |
|
|
|
matches.sort(key=lambda m: m.start_date, reverse=True) |
|
|
|
matches.sort(key=lambda m: m.start_date, reverse=True) |
|
|
|
return matches |
|
|
|
return matches |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def display_summons(self): |
|
|
|
|
|
|
|
if self.end_date is not None: |
|
|
|
|
|
|
|
return False |
|
|
|
|
|
|
|
if self.publish_summons: |
|
|
|
|
|
|
|
return True |
|
|
|
|
|
|
|
if timezone.now().date() >= self.start_date.date(): |
|
|
|
|
|
|
|
return True |
|
|
|
|
|
|
|
return False |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def display_group_stages(self): |
|
|
|
|
|
|
|
if len(self.groupstage_set.all()) == 0: |
|
|
|
|
|
|
|
return False |
|
|
|
|
|
|
|
if self.publish_group_stages: |
|
|
|
|
|
|
|
return True |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
first_group_stage_start_date = self.group_stage_start_date() |
|
|
|
|
|
|
|
if first_group_stage_start_date is None: |
|
|
|
|
|
|
|
return False |
|
|
|
|
|
|
|
elif timezone.now().date() >= first_group_stage_start_date.date(): |
|
|
|
|
|
|
|
return True |
|
|
|
|
|
|
|
return False |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def group_stage_start_date(self): |
|
|
|
|
|
|
|
group_stages = [gs for gs in self.groupstage_set.all() if gs.start_date is not None] |
|
|
|
|
|
|
|
return min(group_stages, key=lambda gs: gs.start_date).start_date |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def display_matches(self): |
|
|
|
|
|
|
|
bracket_matches = self.bracket_matches() |
|
|
|
|
|
|
|
if len(bracket_matches) == 0: |
|
|
|
|
|
|
|
return False |
|
|
|
|
|
|
|
if self.publish_brackets: |
|
|
|
|
|
|
|
return True |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
first_match_start_date = self.first_match_start_date(bracket_matches) |
|
|
|
|
|
|
|
if first_match_start_date is None: |
|
|
|
|
|
|
|
return False |
|
|
|
|
|
|
|
elif timezone.now().date() >= first_match_start_date.date(): |
|
|
|
|
|
|
|
return True |
|
|
|
|
|
|
|
return False |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def bracket_matches(self): |
|
|
|
|
|
|
|
matches = [] |
|
|
|
|
|
|
|
for round in self.round_set.all(): |
|
|
|
|
|
|
|
matches.extend(round.all_matches(False)) |
|
|
|
|
|
|
|
return matches |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def first_match_start_date(self, bracket_matches): |
|
|
|
|
|
|
|
matches = [m for m in bracket_matches if m.start_date is not None] |
|
|
|
|
|
|
|
return min(matches, key=lambda m: m.start_date).start_date |
|
|
|
|
|
|
|
|
|
|
|
class MatchGroup: |
|
|
|
class MatchGroup: |
|
|
|
def __init__(self, name, matches): |
|
|
|
def __init__(self, name, matches): |
|
|
|
self.name = name |
|
|
|
self.name = name |
|
|
|
|