From e6526cbb8f091a7cb2a01454993f13fc24e2d286 Mon Sep 17 00:00:00 2001 From: Raz Date: Wed, 11 Dec 2024 18:04:55 +0100 Subject: [PATCH] fix ui --- tournaments/forms.py | 2 +- tournaments/models/enums.py | 12 ++-- tournaments/models/team_registration.py | 3 + tournaments/models/tournament.py | 56 ++++++++++++++----- tournaments/static/tournaments/css/style.css | 56 ++++++++----------- tournaments/templates/profile.html | 8 +-- .../templates/register_tournament.html | 18 +++++- .../tournaments/navigation_base.html | 8 ++- .../tournaments/navigation_tournament.html | 26 ++++----- .../tournaments/tournament_info.html | 21 ++++++- .../templates/tournaments/tournament_row.html | 2 +- .../templates/tournaments/tournaments.html | 5 -- tournaments/views.py | 39 +++++++++---- 13 files changed, 161 insertions(+), 95 deletions(-) diff --git a/tournaments/forms.py b/tournaments/forms.py index 21d95f7..c13c0a2 100644 --- a/tournaments/forms.py +++ b/tournaments/forms.py @@ -47,7 +47,7 @@ class SimpleForm(forms.Form): class TournamentRegistrationForm(forms.Form): #first_name = forms.CharField(label='Prénom', max_length=50) #last_name = forms.CharField(label='Nom', max_length=50) - email = forms.EmailField(label='E-mail') + email = forms.EmailField(label='E-mail', widget=forms.EmailInput(attrs={'readonly': 'readonly'})) mobile_number = forms.CharField( label='Téléphone (facultatif)', max_length=15, diff --git a/tournaments/models/enums.py b/tournaments/models/enums.py index 255df99..29225cb 100644 --- a/tournaments/models/enums.py +++ b/tournaments/models/enums.py @@ -92,11 +92,10 @@ class OnlineRegistrationStatus(models.IntegerChoices): NOT_ENABLED = 2, 'Not Enabled' NOT_STARTED = 3, 'Not Started' ENDED = 4, 'Ended' - REGISTRATION_FULL = 5, 'Registration Full' - WAITING_LIST_POSSIBLE = 6, 'Waiting List Possible' - WAITING_LIST_FULL = 7, 'Waiting List Full' - IN_PROGRESS = 8, 'In Progress' - ENDED_WITH_RESULTS = 9, 'Ended with Results' + WAITING_LIST_POSSIBLE = 5, 'Waiting List Possible' + WAITING_LIST_FULL = 6, 'Waiting List Full' + IN_PROGRESS = 7, 'In Progress' + ENDED_WITH_RESULTS = 8, 'Ended with Results' def status_localized(self) -> str: status_map = { @@ -104,8 +103,7 @@ class OnlineRegistrationStatus(models.IntegerChoices): OnlineRegistrationStatus.NOT_ENABLED: "Inscription désactivée", OnlineRegistrationStatus.NOT_STARTED: "Inscription pas encore ouverte", OnlineRegistrationStatus.ENDED: "Inscription terminée", - OnlineRegistrationStatus.REGISTRATION_FULL: "Inscription complète", - OnlineRegistrationStatus.WAITING_LIST_POSSIBLE: "Liste d'attente disponible", + OnlineRegistrationStatus.WAITING_LIST_POSSIBLE: "Liste d'attente ouverte", OnlineRegistrationStatus.WAITING_LIST_FULL: "Liste d'attente complète", OnlineRegistrationStatus.IN_PROGRESS: "Tournoi en cours", OnlineRegistrationStatus.ENDED_WITH_RESULTS: "Tournoi terminé" diff --git a/tournaments/models/team_registration.py b/tournaments/models/team_registration.py index a040e90..148a2d2 100644 --- a/tournaments/models/team_registration.py +++ b/tournaments/models/team_registration.py @@ -125,3 +125,6 @@ class TeamRegistration(models.Model): if p != player: return p return None + + def is_in_waiting_list(self): + return self.tournament.get_team_waiting_list_position(self) diff --git a/tournaments/models/tournament.py b/tournaments/models/tournament.py index d01cf87..afb46c5 100644 --- a/tournaments/models/tournament.py +++ b/tournaments/models/tournament.py @@ -200,7 +200,9 @@ class Tournament(models.Model): def registration_count_display(self): teams = self.teams(True) - if teams is not None and len(teams) > 0: + if teams is not None and len(teams) == 1: + return f"{len(teams)} équipe inscrite" + elif teams is not None and len(teams) > 1: return f"{len(teams)} équipes inscrites" else: return None @@ -295,6 +297,18 @@ class Tournament(models.Model): rankings.sort(key=lambda r: r.ranking) return rankings + def get_team_waiting_list_position(self, team_registration): + # Use the teams method to get sorted list of teams + all_teams = self.teams(True) + waiting_teams = [t for t in all_teams if t.stage == "Attente"] + + # Find matching team in waiting list and return its index + for i, team in enumerate(waiting_teams): + if team.team_registration.id == team_registration.id: + return i + + return -1 # Team not found in waiting list + def teams(self, includeWaitingList): # print("Starting teams method") bracket_teams = [] @@ -988,17 +1002,7 @@ class Tournament(models.Model): waiting_list_count = current_team_count - self.target_team_count if waiting_list_count >= self.waiting_list_limit: return OnlineRegistrationStatus.WAITING_LIST_FULL - return OnlineRegistrationStatus.WAITING_LIST_POSSIBLE - return OnlineRegistrationStatus.REGISTRATION_FULL - current_team_count = self.teamregistration_set.filter(walk_out=False).count() - if current_team_count >= self.target_team_count: - if self.waiting_list_limit is not None: - waiting_list_count = current_team_count - self.target_team_count - if waiting_list_count >= self.waiting_list_limit: - return OnlineRegistrationStatus.WAITING_LIST_FULL - return OnlineRegistrationStatus.WAITING_LIST_POSSIBLE - return OnlineRegistrationStatus.REGISTRATION_FULL - + return OnlineRegistrationStatus.WAITING_LIST_POSSIBLE return OnlineRegistrationStatus.OPEN def is_unregistration_possible(self): @@ -1021,9 +1025,35 @@ class Tournament(models.Model): # Otherwise unregistration is allowed return True + def get_waiting_list_position(self): + # If no target team count exists, no one goes to waiting list + if self.target_team_count is None: + return -1 + + # 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]) + + # If current count is less than target count, next team is not in waiting list + if current_team_count < self.target_team_count: + return -1 + + # If we have a waiting list limit + if self.waiting_list_limit is not None: + waiting_list_count = current_team_count - self.target_team_count + # If waiting list is full + if waiting_list_count >= self.waiting_list_limit: + return -1 + # Return waiting list position + return waiting_list_count + + # In waiting list with no limit + return current_team_count - self.target_team_count + def build_tournament_details_str(self): tournament_details = [] - tournament_details.append(self.level()) + + if self.federal_level_category > 0: + tournament_details.append(self.level()) if self.category(): tournament_details.append(self.category()) if self.age(): diff --git a/tournaments/static/tournaments/css/style.css b/tournaments/static/tournaments/css/style.css index 38ad109..220493d 100644 --- a/tournaments/static/tournaments/css/style.css +++ b/tournaments/static/tournaments/css/style.css @@ -82,6 +82,26 @@ nav a { font-weight: 600; } +nav a.orange { + color: white; + background-color: #f39200; +} + +nav a.orange:hover { + color: #1b223a; /* Same text color on hover */ + text-decoration: none; /* Prevent underline on hover */ +} + +nav a.red { + color: white; + background-color: #e84038; +} + +nav a.red:hover { + color: white; /* Same text color on hover */ + background-color: #1b223a; +} + hr { margin: 2px 0px; } @@ -323,7 +343,7 @@ tr { } .red { - background-color: red; + background-color: #e84038; } svg { @@ -712,7 +732,7 @@ h-margin { } .alert { - color: red; /* Make the text red */ + color: #e84038; /* Make the text red */ font-weight: bold; /* Optional: Make the text bold */ } @@ -725,35 +745,3 @@ h-margin { background-color: #cc0000; /* Darker red on hover */ color: white; /* White text on hover */ } - -.top-link { - display: block; - text-align: center; - margin-top: 10px; - font-style: italic; - text-decoration: underline; -} - -.login-buttons { - position: relative; - display: flex; - margin-left: 10px; - gap: 10px; - padding: 0px; -} - -.login-buttons .button { - display: block; - padding: 8px 8px; - border: none; - background: none; - border-radius: 4px; - text-align: center; - text-decoration: underline; - color: #333; - transition: background 0.2s; -} - -.login-buttons .button:hover { - background: #f39200; -} diff --git a/tournaments/templates/profile.html b/tournaments/templates/profile.html index b3b68ad..f0a2dfa 100644 --- a/tournaments/templates/profile.html +++ b/tournaments/templates/profile.html @@ -6,12 +6,12 @@ {% block content %}