fix empty matches stuff

clubs
Razmig Sarkissian 1 year ago
parent c1832e758b
commit f96da28146
  1. 34
      tournaments/models/tournament.py
  2. 3
      tournaments/templates/tournaments/matches.html
  3. 2
      tournaments/templates/tournaments/team_row.html

@ -269,15 +269,21 @@ class Tournament(models.Model):
groups = [] groups = []
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))
for group_stage in self.groupstage_set.all():
group = self.group_stage_match_group(group_stage, broadcasted, hide_empty_matches=True) if self.display_group_stages():
if group: for group_stage in self.groupstage_set.all().order_by('index'):
groups.append(group) group = self.group_stage_match_group(group_stage, broadcasted, hide_empty_matches=True)
if group:
groups.append(group)
return groups return groups
def group_stage_match_group(self, group_stage, broadcasted, hide_empty_matches): def group_stage_match_group(self, group_stage, broadcasted, hide_empty_matches):
matches = group_stage.match_set.all() matches = group_stage.match_set.all()
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]
if matches: if matches:
return self.create_match_group(group_stage.display_name(), matches, broadcasted) return self.create_match_group(group_stage.display_name(), matches, broadcasted)
@ -288,18 +294,22 @@ class Tournament(models.Model):
groups = [] groups = []
matches = round.match_set.order_by('index').all() matches = round.match_set.order_by('index').all()
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]
if matches:
round_matches = round.match_set.all()
if hide_empty_matches:
round_matches = [m for m in round_matches if m.should_appear()]
group = self.create_match_group(round.name(), round_matches, broadcasted) if matches:
group = self.create_match_group(round.name(), matches, broadcasted)
groups.append(group) groups.append(group)
ranking_matches = round.ranking_matches(hide_empty_matches) ranking_matches = round.ranking_matches(hide_empty_matches)
ranking_matches = [m for m in ranking_matches if m.should_appear()] if hide_empty_matches:
ranking_matches = [m for m in ranking_matches if m.should_appear()]
else:
ranking_matches = [m for m in ranking_matches if m.disabled is False]
if len(ranking_matches) > 0: if len(ranking_matches) > 0:
group = self.create_match_group('Matchs de classement', ranking_matches, broadcasted) group = self.create_match_group('Matchs de classement', ranking_matches, broadcasted)
groups.append(group) groups.append(group)

@ -13,9 +13,12 @@
{% 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>
{% if tournament.display_group_stages %}
{% for group_stage in group_stages %} {% for group_stage in group_stages %}
<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 %}
{% 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 %}

@ -7,7 +7,7 @@
<div>{{ name }}</div> <div>{{ name }}</div>
{% endfor %} {% endfor %}
</div> </div>
{% if hide_teams_weight %} {% if tournament.hide_teams_weight %}
<div class="table-cell right horizontal-padding"></div> <div class="table-cell right horizontal-padding"></div>
{% else %} {% else %}
<div class="table-cell right horizontal-padding">{{ team.weight }}</div> <div class="table-cell right horizontal-padding">{{ team.weight }}</div>

Loading…
Cancel
Save