Fix crash in previous algo

clubs
Laurent 2 years ago
parent 125b5e1517
commit d05de12e7b
  1. 9
      tournaments/models/tournament.py

@ -196,9 +196,16 @@ class Tournament(models.Model):
matches.extend(group_stage.match_set.all()) matches.extend(group_stage.match_set.all())
return matches return matches
def group_stage_matches(self):
matches = []
for group_stage in self.groupstage_set.all():
matches.extend(group_stage.match_set.all())
return matches
def group_stages_running(self): def group_stages_running(self):
if len(self.groupstage_set.all()) > 0: if len(self.groupstage_set.all()) > 0:
running_group_stage_matches = Match.objects.filter(group_stage__is_null=False, end_date=None) matches = self.group_stage_matches()
running_group_stage_matches = [m for m in matches if m.end_date is None]
return len(running_group_stage_matches) > 0 return len(running_group_stage_matches) > 0
else: else:
return False return False

Loading…
Cancel
Save