Laurent 1 year ago
commit 3da08ccd2f
  1. 1
      api/serializers.py
  2. 2
      tournaments/admin.py
  3. 2
      tournaments/models/group_stage.py
  4. 1
      tournaments/models/round.py
  5. 12
      tournaments/models/tournament.py
  6. 4
      tournaments/templates/tournaments/matches.html
  7. 2
      tournaments/templates/tournaments/navigation_tournament.html
  8. 2
      tournaments/views.py

@ -67,6 +67,7 @@ class UserSerializer(serializers.ModelSerializer):
bracket_match_format_preference=validated_data.get('bracket_match_format_preference'), bracket_match_format_preference=validated_data.get('bracket_match_format_preference'),
group_stage_match_format_preference=validated_data.get('group_stage_match_format_preference'), group_stage_match_format_preference=validated_data.get('group_stage_match_format_preference'),
loser_bracket_match_format_preference=validated_data.get('loser_bracket_match_format_preference'), loser_bracket_match_format_preference=validated_data.get('loser_bracket_match_format_preference'),
loser_bracket_mode=validated_data.get('loser_bracket_mode'),
) )
self.send_email(self.context['request'], user) self.send_email(self.context['request'], user)

@ -23,7 +23,7 @@ class CustomUserAdmin(UserAdmin):
'summons_message_body', 'summons_message_signature', 'summons_available_payment_methods', 'summons_message_body', 'summons_message_signature', 'summons_available_payment_methods',
'summons_display_format', 'summons_display_entry_fee', 'summons_use_full_custom_message', 'summons_display_format', 'summons_display_entry_fee', 'summons_use_full_custom_message',
'match_formats_default_duration', 'bracket_match_format_preference', 'group_stage_match_format_preference', 'match_formats_default_duration', 'bracket_match_format_preference', 'group_stage_match_format_preference',
'loser_bracket_match_format_preference', 'device_id' 'loser_bracket_match_format_preference', 'device_id', 'loser_bracket_mode'
]}), ]}),
] ]
add_fieldsets = [ add_fieldsets = [

@ -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

@ -59,7 +59,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:

@ -349,13 +349,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)
@ -364,8 +366,10 @@ class Tournament(models.Model):
def all_groups(self, broadcasted): def all_groups(self, broadcasted):
groups = [] 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(): if self.display_group_stages():
for group_stage in self.groupstage_set.all().order_by('index'): 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): 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