diff --git a/tournaments/models/group_stage.py b/tournaments/models/group_stage.py
index 85415a9..a902a93 100644
--- a/tournaments/models/group_stage.py
+++ b/tournaments/models/group_stage.py
@@ -104,7 +104,7 @@ class GroupStage(models.Model):
def has_at_least_one_started_match(self):
for match in self.match_set.all():
- if match.start_date:
+ if match.start_date is not None and match.start_date <= timezone.now():
return True
return False
diff --git a/tournaments/models/round.py b/tournaments/models/round.py
index 08729a6..4f5a348 100644
--- a/tournaments/models/round.py
+++ b/tournaments/models/round.py
@@ -59,7 +59,6 @@ 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
- 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:
diff --git a/tournaments/models/tournament.py b/tournaments/models/tournament.py
index 03de6aa..063a7a0 100644
--- a/tournaments/models/tournament.py
+++ b/tournaments/models/tournament.py
@@ -349,13 +349,15 @@ class Tournament(models.Model):
def match_groups(self, broadcasted, group_stage_id, round_id):
+ display_brackets = self.display_matches()
+
match_groups = []
if group_stage_id:
group_stage = self.groupstage_set.filter(id=group_stage_id).first()
match_groups.append(self.group_stage_match_group(group_stage, broadcasted, hide_empty_matches=False))
elif round_id:
round = self.round_set.filter(id=round_id).first()
- if round:
+ if round and display_brackets is True:
match_groups = self.round_match_groups(round, broadcasted, hide_empty_matches=False)
else:
match_groups = self.all_groups(broadcasted)
@@ -364,8 +366,10 @@ class Tournament(models.Model):
def all_groups(self, broadcasted):
groups = []
- for round in self.round_set.filter(parent=None).all().order_by('index'):
- groups.extend(self.round_match_groups(round, broadcasted, hide_empty_matches=True))
+
+ if self.display_matches():
+ for round in self.round_set.filter(parent=None).all().order_by('index'):
+ groups.extend(self.round_match_groups(round, broadcasted, hide_empty_matches=True))
if self.display_group_stages():
for group_stage in self.groupstage_set.all().order_by('index'):
@@ -697,7 +701,7 @@ class Tournament(models.Model):
def has_all_group_stages_started(self):
for group_stage in self.groupstage_set.all():
- if group_stage.has_at_least_one_started_match() == False:
+ if group_stage.has_at_least_one_started_match() is False:
return False
return True
diff --git a/tournaments/templates/tournaments/matches.html b/tournaments/templates/tournaments/matches.html
index 9080ded..0f5090c 100644
--- a/tournaments/templates/tournaments/matches.html
+++ b/tournaments/templates/tournaments/matches.html
@@ -9,7 +9,7 @@
{% include 'tournaments/navigation_tournament.html' %}
-{% if tournament.display_matches %}
+{% if tournament.display_matches or tournament.display_group_stages %}
{% if rounds or group_stages %}
{% endif %}
diff --git a/tournaments/templates/tournaments/navigation_tournament.html b/tournaments/templates/tournaments/navigation_tournament.html
index cb26aad..b219178 100644
--- a/tournaments/templates/tournaments/navigation_tournament.html
+++ b/tournaments/templates/tournaments/navigation_tournament.html
@@ -2,7 +2,7 @@
Informations
- {% if tournament.display_matches %}
+ {% if tournament.display_matches or tournament.display_group_stages %}
Matches
{% endif %}
diff --git a/tournaments/views.py b/tournaments/views.py
index 73a2781..cd5ab8e 100644
--- a/tournaments/views.py
+++ b/tournaments/views.py
@@ -151,7 +151,7 @@ def tournament(request, tournament_id):
print(len(rounds))
print(len(group_stages))
- if tournament.display_matches():
+ if tournament.display_matches() or tournament.display_group_stages():
return render(request, 'tournaments/matches.html', {
'tournament': tournament,
'rounds': rounds,