diff --git a/tournaments/models/player_registration.py b/tournaments/models/player_registration.py index 13a7018..98a3217 100644 --- a/tournaments/models/player_registration.py +++ b/tournaments/models/player_registration.py @@ -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' diff --git a/tournaments/models/tournament.py b/tournaments/models/tournament.py index ec85950..903d8ef 100644 --- a/tournaments/models/tournament.py +++ b/tournaments/models/tournament.py @@ -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): diff --git a/tournaments/templates/tournaments/tournament_row.html b/tournaments/templates/tournaments/tournament_row.html index f256e33..53f9f7b 100644 --- a/tournaments/templates/tournaments/tournament_row.html +++ b/tournaments/templates/tournaments/tournament_row.html @@ -42,8 +42,12 @@ {% endif %} {% else %} + {% if tournament.is_team_tournament %}
Équipes
-
{{ tournament.get_tournament_status_team_count }}
+ {% else %} +
Inscriptions
+ {% endif %} +
{{ tournament.get_tournament_status_registration_count }}
{% if status.display_box %}
{{ status.short_label }} @@ -52,8 +56,12 @@ {% endif %} {% endwith %} {% else %} + {% if tournament.is_team_tournament %}
Équipes
-
{{ tournament.get_tournament_status_team_count }}
+ {% else %} +
Inscriptions
+ {% endif %} +
{{ tournament.get_tournament_status_registration_count }}
{% if status.display_box %}
{{ status.short_label }}