Laurent 1 year ago
commit 9f42696283
  1. 33
      tournaments/migrations/0068_tournament_hide_points_earned_and_more.py
  2. 3
      tournaments/models/enums.py
  3. 11
      tournaments/models/tournament.py
  4. 6
      tournaments/templates/tournaments/group_stage_cell.html
  5. 2
      tournaments/templates/tournaments/match_cell.html
  6. 6
      tournaments/templates/tournaments/ranking_row.html
  7. 2
      tournaments/templates/tournaments/team_row.html

@ -0,0 +1,33 @@
# Generated by Django 4.2.11 on 2024-06-11 16:22
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('tournaments', '0067_alter_customuser_email'),
]
operations = [
migrations.AddField(
model_name='tournament',
name='hide_points_earned',
field=models.BooleanField(default=False),
),
migrations.AlterField(
model_name='tournament',
name='federal_age_category',
field=models.IntegerField(choices=[(0, 'Aucune'), (120, 'A11_12'), (140, 'A13_14'), (160, 'A15_16'), (180, 'A17_18'), (200, 'SENIOR'), (450, 'A45'), (550, 'A55')], default=200),
),
migrations.AlterField(
model_name='tournament',
name='federal_category',
field=models.IntegerField(choices=[(0, 'Homme'), (1, 'Femme'), (2, 'Mixte'), (3, 'Aucune')], default=0),
),
migrations.AlterField(
model_name='tournament',
name='federal_level_category',
field=models.IntegerField(choices=[(0, 'Animation'), (25, 'P25'), (100, 'P100'), (250, 'P250'), (500, 'P500'), (1000, 'P1000'), (1500, 'P1500'), (2000, 'P2000')], default=100),
),
]

@ -11,8 +11,10 @@ class FederalCategory(models.IntegerChoices):
MEN = 0, 'Homme' MEN = 0, 'Homme'
WOMEN = 1, 'Femme' WOMEN = 1, 'Femme'
MIXED = 2, 'Mixte' MIXED = 2, 'Mixte'
UNLISTED = 3, ''
class FederalLevelCategory(models.IntegerChoices): class FederalLevelCategory(models.IntegerChoices):
UNLISTED = 0, 'Animation'
P25 = 25, 'P25' P25 = 25, 'P25'
P100 = 100, 'P100' P100 = 100, 'P100'
P250 = 250, 'P250' P250 = 250, 'P250'
@ -22,6 +24,7 @@ class FederalLevelCategory(models.IntegerChoices):
P2000 = 2000, 'P2000' P2000 = 2000, 'P2000'
class FederalAgeCategory(models.IntegerChoices): class FederalAgeCategory(models.IntegerChoices):
UNLISTED = 0, ''
A11_12 = 120, 'A11_12' A11_12 = 120, 'A11_12'
A13_14 = 140, 'A13_14' A13_14 = 140, 'A13_14'
A15_16 = 160, 'A15_16' A15_16 = 160, 'A15_16'

@ -56,6 +56,7 @@ class Tournament(models.Model):
should_verify_bracket = models.BooleanField(default=False) should_verify_bracket = models.BooleanField(default=False)
should_verify_group_stage = models.BooleanField(default=False) should_verify_group_stage = models.BooleanField(default=False)
publish_tournament = models.BooleanField(default=False) publish_tournament = models.BooleanField(default=False)
hide_points_earned = models.BooleanField(default=False)
def __str__(self): def __str__(self):
if self.name: if self.name:
@ -507,7 +508,7 @@ class Tournament(models.Model):
first_group_stage_start_date = self.group_stage_start_date() first_group_stage_start_date = self.group_stage_start_date()
if first_group_stage_start_date is None: if first_group_stage_start_date is None:
return False return datetime.now().date() >= self.start_date.date()
group_stage_start_date = self.getEightAm(first_group_stage_start_date) group_stage_start_date = self.getEightAm(first_group_stage_start_date)
@ -537,7 +538,7 @@ class Tournament(models.Model):
first_match_start_date = self.first_match_start_date(bracket_matches) first_match_start_date = self.first_match_start_date(bracket_matches)
if first_match_start_date is None: if first_match_start_date is None:
return False return datetime.now().date() >= self.start_date.date()
bracket_start_date = self.getEightAm(first_match_start_date) bracket_start_date = self.getEightAm(first_match_start_date)
if bracket_start_date < self.start_date: if bracket_start_date < self.start_date:
@ -568,6 +569,12 @@ class Tournament(models.Model):
end = self.start_date + timedelta(days=self.day_duration + 2) end = self.start_date + timedelta(days=self.day_duration + 2)
return self.start_date.replace(hour=0, minute=0) <= timezone.now() <= end return self.start_date.replace(hour=0, minute=0) <= timezone.now() <= end
def display_points_earned(self):
return self.federal_level_category != FederalLevelCategory.UNLISTED and self.hide_points_earned is False
def hide_weight(self):
return self.federal_level_category == FederalLevelCategory.UNLISTED
class MatchGroup: class MatchGroup:
def __init__(self, name, matches): def __init__(self, name, matches):
self.name = name self.name = name

@ -22,7 +22,11 @@
</div> </div>
<div class="flex-right"> <div class="flex-right">
{% if team.match_count == 0 %} {% if team.match_count == 0 %}
<div class="score ws">{{ team.weight }}</div> {% if tournament.hide_weight %}
<div class="score ws"></div>
{% else %}
<div class="score ws">{{ team.weight }}</div>
{% endif %}
{% else %} {% else %}
<div class="center"> <div class="center">
<div class="score ws">{{ team.wins_losses }}</div> <div class="score ws">{{ team.wins_losses }}</div>

@ -34,7 +34,7 @@
{% endif %} {% endif %}
</div> </div>
{% else %} {% elif not tournament.hide_weight %}
<span class="score ws">{{ team.weight }}</span> <span class="score ws">{{ team.weight }}</span>
{% endif %} {% endif %}
</div> </div>

@ -9,5 +9,9 @@
{% endfor %} {% endfor %}
</div> </div>
<div class="table-cell right horizontal-padding">{{ ranking.points }}</div> {% if tournament.display_points_earned %}
<div class="table-cell right horizontal-padding">{{ ranking.points }}</div>
{% else %}
<div class="table-cell right horizontal-padding"></div>
{% endif %}
</div> </div>

@ -9,6 +9,8 @@
</div> </div>
{% if tournament.hide_teams_weight %} {% if tournament.hide_teams_weight %}
<div class="table-cell right horizontal-padding"></div> <div class="table-cell right horizontal-padding"></div>
{% elif tournament.hide_weight %}
<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>
{% endif %} {% endif %}

Loading…
Cancel
Save