|
|
|
|
@ -51,6 +51,8 @@ class PlayerRegistration(TournamentSubModel): |
|
|
|
|
contact_email = models.CharField(max_length=50, null=True, blank=True) |
|
|
|
|
contact_name = models.CharField(max_length=200, null=True, blank=True) |
|
|
|
|
|
|
|
|
|
is_anonymous = models.BooleanField(default=False) |
|
|
|
|
|
|
|
|
|
def delete_dependencies(self): |
|
|
|
|
pass |
|
|
|
|
|
|
|
|
|
@ -74,9 +76,13 @@ class PlayerRegistration(TournamentSubModel): |
|
|
|
|
# return None |
|
|
|
|
|
|
|
|
|
def name(self): |
|
|
|
|
if self.is_anonymous: |
|
|
|
|
return "Joueur Anonyme" |
|
|
|
|
return f"{self.first_name} {self.last_name}" |
|
|
|
|
|
|
|
|
|
def shortened_name(self, forced=False): |
|
|
|
|
if self.is_anonymous: |
|
|
|
|
return "Anonyme" |
|
|
|
|
name = self.name() |
|
|
|
|
if (len(name) > 20 or forced) and self.first_name: |
|
|
|
|
name = f"{self.first_name[0]}. {self.last_name}" |
|
|
|
|
@ -86,11 +92,15 @@ class PlayerRegistration(TournamentSubModel): |
|
|
|
|
return name |
|
|
|
|
|
|
|
|
|
def clean_club_name(self): |
|
|
|
|
if self.is_anonymous: |
|
|
|
|
return "Anonyme" |
|
|
|
|
if self.club_name: |
|
|
|
|
return self.club_name.split(' (')[0] |
|
|
|
|
return "Non renseigné" |
|
|
|
|
|
|
|
|
|
def calculate_age(self): |
|
|
|
|
if self.is_anonymous: |
|
|
|
|
return None |
|
|
|
|
if self.birthdate: |
|
|
|
|
try: |
|
|
|
|
birth_year = int(self.birthdate[-4:]) # Assumes birthdate ends with YYYY |
|
|
|
|
|