From ad6139852de4144dd6117ddf6fd3df1398001479 Mon Sep 17 00:00:00 2001 From: Razmig Sarkissian Date: Tue, 23 Sep 2025 20:16:47 +0200 Subject: [PATCH] Improve player name display in tournaments Adjust name display logic to handle cases with missing last names and more flexible short name generation for tournament rounds --- tournaments/models/player_registration.py | 4 +++- tournaments/models/round.py | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/tournaments/models/player_registration.py b/tournaments/models/player_registration.py index 5c8cdf6..81879bd 100644 --- a/tournaments/models/player_registration.py +++ b/tournaments/models/player_registration.py @@ -85,7 +85,9 @@ class PlayerRegistration(TournamentSubModel): return "Anonyme" name = self.name() if (len(name) > 20 or forced) and self.first_name: - if self.first_name and len(self.first_name) > 0: + if self.last_name is None: + name = self.first_name + elif self.first_name and len(self.first_name) > 0: name = f"{self.first_name[0]}. {self.last_name}" if len(name) > 20 or forced: name_parts = self.last_name.split(" ") diff --git a/tournaments/models/round.py b/tournaments/models/round.py index e776592..2379a8c 100644 --- a/tournaments/models/round.py +++ b/tournaments/models/round.py @@ -112,6 +112,9 @@ class Round(TournamentSubModel): return True def prepare_match_group(self, next_round, parent_round, loser_final, double_butterfly_mode, secondHalf): + short_names = double_butterfly_mode + if double_butterfly_mode and self.tournament.rounds.count() < 3: + short_names = False matches = self.matches.filter(disabled=False).order_by('index') if len(matches) == 0: return None @@ -211,7 +214,7 @@ class Round(TournamentSubModel): matches=first_half_matches, round_id=self.id, round_index=self.index, - short_names=double_butterfly_mode + short_names=short_names ) return match_group