fix stuff website match and broadcast

bracket-feature
Raz 1 year ago committed by laurent
parent df3167dcf1
commit 7df3242634
  1. 2
      tournaments/models/group_stage.py
  2. 1
      tournaments/models/round.py
  3. 8
      tournaments/models/tournament.py
  4. 4
      tournaments/templates/tournaments/matches.html
  5. 2
      tournaments/templates/tournaments/navigation_tournament.html
  6. 2
      tournaments/views.py

@ -104,7 +104,7 @@ class GroupStage(models.Model):
def has_at_least_one_started_match(self): def has_at_least_one_started_match(self):
for match in self.match_set.all(): 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 True
return False return False

@ -58,7 +58,6 @@ 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()]
if hide_empty_matches: if hide_empty_matches:
matches = [m for m in matches if m.should_appear()] matches = [m for m in matches if m.should_appear()]
else: else:

@ -337,13 +337,15 @@ class Tournament(models.Model):
def match_groups(self, broadcasted, group_stage_id, round_id): def match_groups(self, broadcasted, group_stage_id, round_id):
display_brackets = self.display_matches()
match_groups = [] match_groups = []
if group_stage_id: if group_stage_id:
group_stage = self.groupstage_set.filter(id=group_stage_id).first() 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)) match_groups.append(self.group_stage_match_group(group_stage, broadcasted, hide_empty_matches=False))
elif round_id: elif round_id:
round = self.round_set.filter(id=round_id).first() 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) match_groups = self.round_match_groups(round, broadcasted, hide_empty_matches=False)
else: else:
match_groups = self.all_groups(broadcasted) match_groups = self.all_groups(broadcasted)
@ -352,6 +354,8 @@ class Tournament(models.Model):
def all_groups(self, broadcasted): def all_groups(self, broadcasted):
groups = [] groups = []
if self.display_matches():
for round in self.round_set.filter(parent=None).all().order_by('index'): 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)) groups.extend(self.round_match_groups(round, broadcasted, hide_empty_matches=True))
@ -685,7 +689,7 @@ class Tournament(models.Model):
def has_all_group_stages_started(self): def has_all_group_stages_started(self):
for group_stage in self.groupstage_set.all(): 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 False
return True return True

@ -9,7 +9,7 @@
{% include 'tournaments/navigation_tournament.html' %} {% include 'tournaments/navigation_tournament.html' %}
{% if tournament.display_matches %} {% if tournament.display_matches or tournament.display_group_stages %}
{% if rounds or group_stages %} {% if rounds or group_stages %}
<nav class="margin10"> <nav class="margin10">
<a href="{% url 'tournament' tournament.id %}" class="mybox topmargin5">Tous les matchs</a> <a href="{% url 'tournament' tournament.id %}" class="mybox topmargin5">Tous les matchs</a>
@ -19,9 +19,11 @@
<a href="{% url 'tournament' tournament.id %}?group_stage={{ group_stage.id }}" class="mybox topmargin5">{{ group_stage.display_name }}</a> <a href="{% url 'tournament' tournament.id %}?group_stage={{ group_stage.id }}" class="mybox topmargin5">{{ group_stage.display_name }}</a>
{% endfor %} {% endfor %}
{% endif %} {% endif %}
{% if tournament.display_matches %}
{% for round in rounds %} {% for round in rounds %}
<a href="{% url 'tournament' tournament.id %}?round={{ round.id }}" class="mybox topmargin5">{{ round.name }}</a> <a href="{% url 'tournament' tournament.id %}?round={{ round.id }}" class="mybox topmargin5">{{ round.name }}</a>
{% endfor %} {% endfor %}
{% endif %}
</nav> </nav>
{% endif %} {% endif %}

@ -2,7 +2,7 @@
<a href="{% url 'tournament-info' tournament.id %}" class="topmargin5">Informations</a> <a href="{% url 'tournament-info' tournament.id %}" class="topmargin5">Informations</a>
{% if tournament.display_matches %} {% if tournament.display_matches or tournament.display_group_stages %}
<a href="{% url 'tournament' tournament.id %}" class="topmargin5">Matches</a> <a href="{% url 'tournament' tournament.id %}" class="topmargin5">Matches</a>
{% endif %} {% endif %}

@ -151,7 +151,7 @@ def tournament(request, tournament_id):
print(len(rounds)) print(len(rounds))
print(len(group_stages)) print(len(group_stages))
if tournament.display_matches(): if tournament.display_matches() or tournament.display_group_stages():
return render(request, 'tournaments/matches.html', { return render(request, 'tournaments/matches.html', {
'tournament': tournament, 'tournament': tournament,
'rounds': rounds, 'rounds': rounds,

Loading…
Cancel
Save