Laurent 1 year ago
commit a24064658a
  1. 2
      tournaments/models/match.py
  2. 6
      tournaments/models/round.py
  3. 15
      tournaments/models/tournament.py

@ -114,7 +114,7 @@ class Match(models.Model):
return False
def should_appear(self):
if self.disabled:
if self.disabled is True:
return False
elif self.group_stage is None:
return (self.start_date or self.end_date) and len(self.team_scores.all()) > 0

@ -35,8 +35,7 @@ class Round(models.Model):
for child in self.children.all():
child_matches = child.match_set.all()
if hide_empty_matches:
child_matches = [m for m in child_matches if m.should_appear()]
child_matches = [m for m in child_matches if m.should_appear()]
matches.extend(child_matches)
matches.extend(child.ranking_matches(hide_empty_matches))
@ -50,8 +49,7 @@ class Round(models.Model):
def get_matches_recursive(self, hide_empty_matches):
matches = list(self.match_set.all()) # Retrieve matches associated with the current round
if hide_empty_matches:
matches = [m for m in matches if m.should_appear()]
matches = [m for m in matches if m.should_appear()]
# Recursively fetch matches from child rounds
for child_round in self.children.all():

@ -277,8 +277,7 @@ class Tournament(models.Model):
def group_stage_match_group(self, group_stage, broadcasted, hide_empty_matches):
matches = group_stage.match_set.all()
if hide_empty_matches:
matches = [m for m in matches if m.should_appear()]
matches = [m for m in matches if m.should_appear()]
if matches:
return self.create_match_group(group_stage.display_name(), matches, broadcasted)
@ -289,14 +288,17 @@ class Tournament(models.Model):
groups = []
matches = round.match_set.order_by('index').all()
if hide_empty_matches:
matches = [m for m in matches if m.should_appear()]
matches = [m for m in matches if m.should_appear()]
if matches:
group = self.create_match_group(round.name(), round.match_set.all(), broadcasted)
round_matches = round.match_set.all()
round_matches = [m for m in round_matches if m.should_appear()]
group = self.create_match_group(round.name(), round_matches, broadcasted)
groups.append(group)
ranking_matches = round.ranking_matches(hide_empty_matches)
ranking_matches = [m for m in ranking_matches if m.should_appear()]
if len(ranking_matches) > 0:
group = self.create_match_group('Matchs de classement', ranking_matches, broadcasted)
groups.append(group)
@ -375,8 +377,7 @@ class Tournament(models.Model):
for group_stage in self.groupstage_set.all():
matches.extend(group_stage.match_set.all())
if hide_empty_matches:
matches = [m for m in matches if m.should_appear()]
matches = [m for m in matches if m.should_appear()]
return matches

Loading…
Cancel
Save