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
mailing
Razmig Sarkissian 2 months ago
parent e6a6268143
commit ad6139852d
  1. 4
      tournaments/models/player_registration.py
  2. 5
      tournaments/models/round.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(" ")

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

Loading…
Cancel
Save