Add support for single player tournament registration

The registration system now properly handles both team and individual
player tournaments, displaying the appropriate counts and labels based
on the tournament type.
main
Razmig Sarkissian 1 month ago
parent 2d0dfd1b8f
commit 511066ccc8
  1. 10
      tournaments/models/player_registration.py
  2. 17
      tournaments/models/tournament.py
  3. 12
      tournaments/templates/tournaments/tournament_row.html

@ -138,17 +138,18 @@ class PlayerRegistration(TournamentSubModel):
return None
tournament = self.team_registration.tournament
tournament_status_team_count = tournament.get_tournament_status_team_count()
tournament_status_team_count = tournament.get_tournament_status_registration_count()
# If custom animation type, replace header by "Inscriptions"
if tournament.is_custom_animation():
header = "Inscriptions"
else:
if tournament.is_team_tournament():
header = "Équipes"
else:
header = "Inscriptions"
if tournament.is_canceled():
return {
'header': header,
'position': tournament_status_team_count,
'is_team_tournament': tournament.is_team_tournament(),
'display_box': True,
'box_class': 'light-red',
'short_label': 'annulé'
@ -157,6 +158,7 @@ class PlayerRegistration(TournamentSubModel):
status = {
'header': header,
'position': tournament_status_team_count,
'is_team_tournament': True,
'display_box': True,
'box_class': 'gray',
'short_label': 'inscrit'

@ -96,6 +96,8 @@ class Tournament(BaseModel):
club_member_fee_deduction = models.FloatField(null=True, blank=True)
unregister_delta_in_hours = models.IntegerField(default=24)
currency_code = models.CharField(null=True, blank=True, max_length=3, default='EUR')
parent = models.ForeignKey('self', blank=True, null=True, on_delete=models.SET_NULL, related_name='children')
loser_index = models.IntegerField(default=0)
def delete_dependencies(self):
for team_registration in self.team_registrations.all():
@ -232,7 +234,7 @@ class Tournament(BaseModel):
case AnimationType.CONSOLATION_BRACKET:
return "Consolante"
case AnimationType.CUSTOM:
return "Spécial"
return "Soirée"
case _:
return "Anim."
if self.federal_level_category == 1:
@ -302,8 +304,19 @@ class Tournament(BaseModel):
def get_tournament_status(self):
return self.get_online_registration_status().status_localized()
def get_tournament_status_team_count(self):
def is_team_tournament(self):
return self.minimum_player_per_team >= 2
def get_tournament_status_registration_count(self):
active_teams_count = self.team_registrations.filter(walk_out=False).count()
if self.is_team_tournament() is False:
# Count players instead of teams when minimum players per team is under 2
PlayerRegistration = apps.get_model('tournaments', 'PlayerRegistration')
active_players_count = PlayerRegistration.objects.filter(
team_registration__tournament=self,
team_registration__walk_out=False
).count()
return active_players_count
return min(active_teams_count, self.team_count)
def name_and_event(self):

@ -42,8 +42,12 @@
</div>
{% endif %}
{% else %}
{% if tournament.is_team_tournament %}
<div class="small">Équipes</div>
<div class="very-large">{{ tournament.get_tournament_status_team_count }}</div>
{% else %}
<div class="small">Inscriptions</div>
{% endif %}
<div class="very-large">{{ tournament.get_tournament_status_registration_count }}</div>
{% if status.display_box %}
<div class="box small {{ status.box_class }}">
{{ status.short_label }}
@ -52,8 +56,12 @@
{% endif %}
{% endwith %}
{% else %}
{% if tournament.is_team_tournament %}
<div class="small">Équipes</div>
<div class="very-large">{{ tournament.get_tournament_status_team_count }}</div>
{% else %}
<div class="small">Inscriptions</div>
{% endif %}
<div class="very-large">{{ tournament.get_tournament_status_registration_count }}</div>
{% if status.display_box %}
<div class="box small {{ status.box_class }}">
{{ status.short_label }}

Loading…
Cancel
Save