round hide empty matches

clubs
Razmig Sarkissian 1 year ago
parent 14cdf6293c
commit 6e11af3328
  1. 10
      tournaments/models/round.py

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

Loading…
Cancel
Save