|
|
|
@ -69,7 +69,6 @@ class Tournament(models.Model): |
|
|
|
enable_online_registration = models.BooleanField(default=False) # Equivalent to Bool = false |
|
|
|
enable_online_registration = models.BooleanField(default=False) # Equivalent to Bool = false |
|
|
|
registration_date_limit = models.DateTimeField(null=True, blank=True) # Equivalent to Date? = nil |
|
|
|
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 |
|
|
|
opening_registration_date = models.DateTimeField(null=True, blank=True) # Equivalent to Date? = nil |
|
|
|
target_team_count = models.IntegerField(null=True, blank=True) # Equivalent to Int? = nil |
|
|
|
|
|
|
|
waiting_list_limit = models.IntegerField(null=True, blank=True) # Equivalent to Int? = nil |
|
|
|
waiting_list_limit = models.IntegerField(null=True, blank=True) # Equivalent to Int? = nil |
|
|
|
account_is_required = models.BooleanField(default=True) |
|
|
|
account_is_required = models.BooleanField(default=True) |
|
|
|
license_is_required = models.BooleanField(default=True) |
|
|
|
license_is_required = models.BooleanField(default=True) |
|
|
|
@ -307,14 +306,17 @@ class Tournament(models.Model): |
|
|
|
if team.team_registration.id == team_registration.id: |
|
|
|
if team.team_registration.id == team_registration.id: |
|
|
|
index = i |
|
|
|
index = i |
|
|
|
|
|
|
|
|
|
|
|
# Check if target_team_count exists |
|
|
|
# Check if team_count exists |
|
|
|
if self.target_team_count: |
|
|
|
if self.team_count: |
|
|
|
# Team is not in list |
|
|
|
# Team is not in list |
|
|
|
if index < self.target_team_count: |
|
|
|
if index < self.team_count: |
|
|
|
|
|
|
|
print("Team is not in list", index, self.team_count) |
|
|
|
return -1 |
|
|
|
return -1 |
|
|
|
# Return position in waiting list relative to target count |
|
|
|
# Return position in waiting list relative to target count |
|
|
|
return index - self.target_team_count |
|
|
|
print("Return position in waiting list relative to target count", index, self.team_count) |
|
|
|
|
|
|
|
return index - self.team_count |
|
|
|
else: |
|
|
|
else: |
|
|
|
|
|
|
|
print("else", index, self.team_count) |
|
|
|
return -1 |
|
|
|
return -1 |
|
|
|
|
|
|
|
|
|
|
|
def teams(self, includeWaitingList): |
|
|
|
def teams(self, includeWaitingList): |
|
|
|
@ -380,7 +382,7 @@ class Tournament(models.Model): |
|
|
|
# print(f"Group stage members count: {group_stage_members_count}") |
|
|
|
# print(f"Group stage members count: {group_stage_members_count}") |
|
|
|
|
|
|
|
|
|
|
|
if self.team_sorting == TeamSortingType.INSCRIPTION_DATE: |
|
|
|
if self.team_sorting == TeamSortingType.INSCRIPTION_DATE: |
|
|
|
complete_teams.sort(key=lambda s: (s.date is None, s.date or datetime.min, s.initial_weight, s.team_registration.id)) |
|
|
|
complete_teams.sort(key=lambda s: (s.registration_date is None, s.registration_date or datetime.min, s.initial_weight, s.team_registration.id)) |
|
|
|
else: |
|
|
|
else: |
|
|
|
complete_teams.sort(key=lambda s: (s.initial_weight, s.team_registration.id)) |
|
|
|
complete_teams.sort(key=lambda s: (s.initial_weight, s.team_registration.id)) |
|
|
|
|
|
|
|
|
|
|
|
@ -409,7 +411,7 @@ class Tournament(models.Model): |
|
|
|
if waiting_list_count > 0: |
|
|
|
if waiting_list_count > 0: |
|
|
|
waiting_teams = waiting_teams + complete_teams[-waiting_list_count:] |
|
|
|
waiting_teams = waiting_teams + complete_teams[-waiting_list_count:] |
|
|
|
if self.team_sorting == TeamSortingType.INSCRIPTION_DATE: |
|
|
|
if self.team_sorting == TeamSortingType.INSCRIPTION_DATE: |
|
|
|
waiting_teams.sort(key=lambda s: (s.date is None, s.date or datetime.min, s.initial_weight, s.team_registration.id)) |
|
|
|
waiting_teams.sort(key=lambda s: (s.registration_date is None, s.registration_date or datetime.min, s.initial_weight, s.team_registration.id)) |
|
|
|
else: |
|
|
|
else: |
|
|
|
waiting_teams.sort(key=lambda s: (s.initial_weight, s.team_registration.id)) |
|
|
|
waiting_teams.sort(key=lambda s: (s.initial_weight, s.team_registration.id)) |
|
|
|
else: |
|
|
|
else: |
|
|
|
@ -923,8 +925,8 @@ class Tournament(models.Model): |
|
|
|
options.append(f"Clôture des inscriptions le {date}") |
|
|
|
options.append(f"Clôture des inscriptions le {date}") |
|
|
|
|
|
|
|
|
|
|
|
# Cible d'équipes |
|
|
|
# Cible d'équipes |
|
|
|
if self.target_team_count: |
|
|
|
if self.team_count: |
|
|
|
options.append(f"Maximum {self.target_team_count} équipes") |
|
|
|
options.append(f"Maximum {self.team_count} équipes") |
|
|
|
|
|
|
|
|
|
|
|
# Liste d'attente |
|
|
|
# Liste d'attente |
|
|
|
if self.waiting_list_limit: |
|
|
|
if self.waiting_list_limit: |
|
|
|
@ -973,11 +975,11 @@ class Tournament(models.Model): |
|
|
|
return False |
|
|
|
return False |
|
|
|
|
|
|
|
|
|
|
|
# Check target team count and waiting list limit |
|
|
|
# Check target team count and waiting list limit |
|
|
|
if self.target_team_count is not None: |
|
|
|
if self.team_count is not None: |
|
|
|
current_team_count = len([tr for tr in self.teamregistration_set.all() if tr.out_of_tournament() is False]) |
|
|
|
current_team_count = len([tr for tr in self.teamregistration_set.all() if tr.out_of_tournament() is False]) |
|
|
|
if current_team_count >= self.target_team_count: |
|
|
|
if current_team_count >= self.team_count: |
|
|
|
if self.waiting_list_limit is not None: |
|
|
|
if self.waiting_list_limit is not None: |
|
|
|
waiting_list_count = current_team_count - self.target_team_count |
|
|
|
waiting_list_count = current_team_count - self.team_count |
|
|
|
if waiting_list_count >= self.waiting_list_limit: |
|
|
|
if waiting_list_count >= self.waiting_list_limit: |
|
|
|
return False |
|
|
|
return False |
|
|
|
return True |
|
|
|
return True |
|
|
|
@ -1002,12 +1004,12 @@ class Tournament(models.Model): |
|
|
|
if now > timezoned_datetime: |
|
|
|
if now > timezoned_datetime: |
|
|
|
return OnlineRegistrationStatus.ENDED |
|
|
|
return OnlineRegistrationStatus.ENDED |
|
|
|
|
|
|
|
|
|
|
|
if self.target_team_count is not None: |
|
|
|
if self.team_count is not None: |
|
|
|
# Get all team registrations excluding walk_outs |
|
|
|
# Get all team registrations excluding walk_outs |
|
|
|
current_team_count = len([tr for tr in self.teamregistration_set.all() if tr.out_of_tournament() is False]) |
|
|
|
current_team_count = len([tr for tr in self.teamregistration_set.all() if tr.out_of_tournament() is False]) |
|
|
|
if current_team_count >= self.target_team_count: |
|
|
|
if current_team_count >= self.team_count: |
|
|
|
if self.waiting_list_limit is not None: |
|
|
|
if self.waiting_list_limit is not None: |
|
|
|
waiting_list_count = current_team_count - self.target_team_count |
|
|
|
waiting_list_count = current_team_count - self.team_count |
|
|
|
if waiting_list_count >= self.waiting_list_limit: |
|
|
|
if waiting_list_count >= self.waiting_list_limit: |
|
|
|
return OnlineRegistrationStatus.WAITING_LIST_FULL |
|
|
|
return OnlineRegistrationStatus.WAITING_LIST_FULL |
|
|
|
return OnlineRegistrationStatus.WAITING_LIST_POSSIBLE |
|
|
|
return OnlineRegistrationStatus.WAITING_LIST_POSSIBLE |
|
|
|
@ -1035,19 +1037,19 @@ class Tournament(models.Model): |
|
|
|
|
|
|
|
|
|
|
|
def get_waiting_list_position(self): |
|
|
|
def get_waiting_list_position(self): |
|
|
|
# If no target team count exists, no one goes to waiting list |
|
|
|
# If no target team count exists, no one goes to waiting list |
|
|
|
if self.target_team_count is None: |
|
|
|
if self.team_count is None: |
|
|
|
return -1 |
|
|
|
return -1 |
|
|
|
|
|
|
|
|
|
|
|
# Get count of active teams (not walked out) |
|
|
|
# Get count of active teams (not walked out) |
|
|
|
current_team_count = len([tr for tr in self.teamregistration_set.all() if tr.out_of_tournament() is False]) |
|
|
|
current_team_count = len([tr for tr in self.teamregistration_set.all() if tr.out_of_tournament() is False]) |
|
|
|
|
|
|
|
|
|
|
|
# If current count is less than target count, next team is not in waiting list |
|
|
|
# If current count is less than target count, next team is not in waiting list |
|
|
|
if current_team_count < self.target_team_count: |
|
|
|
if current_team_count < self.team_count: |
|
|
|
return -1 |
|
|
|
return -1 |
|
|
|
|
|
|
|
|
|
|
|
# If we have a waiting list limit |
|
|
|
# If we have a waiting list limit |
|
|
|
if self.waiting_list_limit is not None: |
|
|
|
if self.waiting_list_limit is not None: |
|
|
|
waiting_list_count = current_team_count - self.target_team_count |
|
|
|
waiting_list_count = current_team_count - self.team_count |
|
|
|
# If waiting list is full |
|
|
|
# If waiting list is full |
|
|
|
if waiting_list_count >= self.waiting_list_limit: |
|
|
|
if waiting_list_count >= self.waiting_list_limit: |
|
|
|
return -1 |
|
|
|
return -1 |
|
|
|
@ -1055,7 +1057,7 @@ class Tournament(models.Model): |
|
|
|
return waiting_list_count |
|
|
|
return waiting_list_count |
|
|
|
|
|
|
|
|
|
|
|
# In waiting list with no limit |
|
|
|
# In waiting list with no limit |
|
|
|
return current_team_count - self.target_team_count |
|
|
|
return current_team_count - self.team_count |
|
|
|
|
|
|
|
|
|
|
|
def build_tournament_details_str(self): |
|
|
|
def build_tournament_details_str(self): |
|
|
|
tournament_details = [] |
|
|
|
tournament_details = [] |
|
|
|
@ -1178,7 +1180,7 @@ class TeamSummon: |
|
|
|
class TeamItem: |
|
|
|
class TeamItem: |
|
|
|
def __init__(self, team_registration): |
|
|
|
def __init__(self, team_registration): |
|
|
|
self.names = team_registration.team_names() |
|
|
|
self.names = team_registration.team_names() |
|
|
|
self.date = team_registration.local_call_date() |
|
|
|
self.registration_date = team_registration.registration_date |
|
|
|
self.weight = team_registration.weight |
|
|
|
self.weight = team_registration.weight |
|
|
|
self.initial_weight = team_registration.initial_weight() |
|
|
|
self.initial_weight = team_registration.initial_weight() |
|
|
|
self.image = team_registration.logo |
|
|
|
self.image = team_registration.logo |
|
|
|
@ -1193,7 +1195,7 @@ class TeamItem: |
|
|
|
def to_dict(self): |
|
|
|
def to_dict(self): |
|
|
|
return { |
|
|
|
return { |
|
|
|
"names": self.names, |
|
|
|
"names": self.names, |
|
|
|
"date": self.date, |
|
|
|
"registration_date": self.registration_date, |
|
|
|
"weight": self.weight, |
|
|
|
"weight": self.weight, |
|
|
|
"initial_weight": self.initial_weight, |
|
|
|
"initial_weight": self.initial_weight, |
|
|
|
"image": self.image, |
|
|
|
"image": self.image, |
|
|
|
|