@ -67,6 +67,7 @@ class Tournament(BaseModel):
initial_seed_round = models . IntegerField ( default = 0 )
initial_seed_count = models . IntegerField ( default = 0 )
enable_online_registration = models . BooleanField ( default = False ) # Equivalent to Bool = false
team_count_limit = models . BooleanField ( default = True )
registration_date_limit = models . DateTimeField ( null = True , blank = True ) # Equivalent to Date? = nil
opening_registration_date = models . DateTimeField ( null = True , blank = True ) # Equivalent to Date? = nil
waiting_list_limit = models . IntegerField ( null = True , blank = True ) # Equivalent to Int? = nil
@ -534,7 +535,7 @@ class Tournament(BaseModel):
if round and matches :
matches . sort ( key = lambda m : m . index )
group = self . create_match_group ( round . name ( ) , matches )
group = self . create_match_group ( round . plural_ name( ) , matches )
groups . append ( group )
ranking_matches = round . ranking_matches ( hide_empty_matches )
@ -1039,7 +1040,7 @@ class Tournament(BaseModel):
return plural_format ( " jour " , self . day_duration )
def has_club_address ( self ) :
if self . event . club :
if self . event and self . event . club :
return self . event . club . has_address ( )
else :
return False
@ -1052,21 +1053,22 @@ class Tournament(BaseModel):
def options_online_registration ( self ) :
options = [ ]
timezone = self . timezone ( )
# Date d'ouverture
if self . opening_registration_date :
date = formats . date_format ( timezone . localtime ( self . opening_registration_dat e) , format = ' j F Y H:i ' )
date = formats . date_format ( self . opening_registration_date . astimezone ( timezon e) , format = ' j F Y H:i ' )
options . append ( f " Ouverture des inscriptions le { date } " )
# Date limite
if self . registration_date_limit :
date = formats . date_format ( timezone . localtime ( self . registration_date_limit ) , format = ' j F Y H:i ' )
date = formats . date_format ( self . registration_date_limit . astimezone ( timezone ) , format = ' j F Y H:i ' )
options . append ( f " Clôture des inscriptions le { date } " )
options . append ( self . get_selection_status_localized )
# Cible d'équipes
if self . team_count :
if self . team_count_limit is True :
options . append ( f " Maximum { self . team_count } équipes " )
# Liste d'attente
@ -1154,7 +1156,7 @@ class Tournament(BaseModel):
if self . team_sorting == TeamSortingType . RANK :
return OnlineRegistrationStatus . OPEN
if self . team_count is not Non e :
if self . team_count_limit is Tru e :
# Get all team registrations excluding walk_outs
current_team_count = self . team_registrations . exclude ( walk_out = True ) . count ( )
if current_team_count > = self . team_count :
@ -1187,16 +1189,13 @@ class Tournament(BaseModel):
def get_waiting_list_position ( self ) :
current_time = timezone . now ( )
current_time = current_time . astimezone ( self . timezone ( ) )
local_registration_federal_limit = self . local_registration_federal_limit ( )
if self . team_sorting == TeamSortingType . RANK and local_registration_federal_limit is not None :
if current_time < local_registration_federal_limit :
return - 1
else :
return 0
# If no target team count exists, no one goes to waiting list
if self . team_count is Non e:
if self . team_count_limit is Fals e:
return - 1
# Get count of active teams (not walked out)
@ -1278,7 +1277,6 @@ class Tournament(BaseModel):
current_year + = 1
user_age = current_year - int ( birth_year )
print ( " user_age " , user_age )
# Check age category restrictions
if self . federal_age_category == FederalAgeCategory . A11_12 and user_age > 12 :
@ -1312,11 +1310,12 @@ class Tournament(BaseModel):
return FederalLevelCategory . min_player_rank ( self . federal_level_category , self . federal_category , self . federal_age_category )
def local_registration_federal_limit ( self ) :
timezone = self . timezone ( )
if self . registration_date_limit is not None :
return self . registration_date_limit
return self . registration_date_limit . astimezone ( timezone )
if self . closed_registration_date is not None :
return self . closed_registration_date
return self . closed_registration_date . astimezone ( timezone )
local_start_date = self . local_start_date ( )
@ -1335,11 +1334,9 @@ class Tournament(BaseModel):
def waiting_list_teams ( self , teams ) :
current_time = timezone . now ( )
current_time = current_time . astimezone ( self . timezone ( ) )
local_registration_federal_limit = self . local_registration_federal_limit ( )
if self . team_sorting == TeamSortingType . RANK and local_registration_federal_limit is not None :
if current_time < local_registration_federal_limit :
print ( " current_time < local_registration_federal_limit " )
return None
if len ( teams ) < = self . team_count :
@ -1349,7 +1346,6 @@ class Tournament(BaseModel):
def first_waiting_list_team ( self , teams ) :
waiting_list_team = self . waiting_list_teams ( teams )
print ( " waiting_list_team " , waiting_list_team )
if waiting_list_team is None :
return None
if len ( waiting_list_team ) > 0 :
@ -1476,21 +1472,21 @@ class Tournament(BaseModel):
else :
return True
def umpire_contact ( self ) :
def umpire_contact ( self ) :
if self . umpire_custom_contact is not None :
print ( self . umpire_custom_contact )
return self . umpire_custom_contact
return self . event . creator . full_name ( )
if self . event and self . event . creator :
return self . event . creator . full_name ( )
else :
return None
def umpire_mail ( self ) :
if self . umpire_custom_mail is not None :
print ( self . umpire_custom_mail )
return self . umpire_custom_mail
return self . event . creator . email
def umpire_phone ( self ) :
if self . umpire_custom_phone is not None :
print ( self . umpire_custom_phone )
return self . umpire_custom_phone
return self . event . creator . phone