From c0d97721dddbcea8d94f711c35892cf59dfc4c89 Mon Sep 17 00:00:00 2001 From: Razmig Sarkissian Date: Tue, 23 Sep 2025 17:43:56 +0200 Subject: [PATCH 1/9] Fix calculation of tournament registration fee --- tournaments/services/tournament_registration.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tournaments/services/tournament_registration.py b/tournaments/services/tournament_registration.py index a8cba10..db6c0d7 100644 --- a/tournaments/services/tournament_registration.py +++ b/tournaments/services/tournament_registration.py @@ -176,8 +176,8 @@ class RegistrationCartManager: players = self.session.get('registration_cart_players', []), entry_fee = tournament.entry_fee if entry_fee is not None and entry_fee > 0 and tournament.enable_online_payment: - fee = entry_fee * tournament.minimum_player_per_team players = self.session.get('registration_cart_players', []) + fee = entry_fee * len(players) club_members = sum(1 for player in players if player.get('club_member', False)) if tournament.club_member_fee_deduction is not None: return fee - club_members * tournament.club_member_fee_deduction From 721650a8b693f58d435b93d1171cce1ecbe5371d Mon Sep 17 00:00:00 2001 From: Razmig Sarkissian Date: Tue, 23 Sep 2025 17:53:20 +0200 Subject: [PATCH 2/9] Fix name display with null checks --- tournaments/models/player_registration.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tournaments/models/player_registration.py b/tournaments/models/player_registration.py index e9d8a83..5c8cdf6 100644 --- a/tournaments/models/player_registration.py +++ b/tournaments/models/player_registration.py @@ -85,10 +85,12 @@ class PlayerRegistration(TournamentSubModel): return "Anonyme" name = self.name() if (len(name) > 20 or forced) and self.first_name: - name = f"{self.first_name[0]}. {self.last_name}" + if 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(" ") - name = f"{self.first_name[0]}. {name_parts[0]}" + if len(name_parts) > 0 and self.first_name and len(self.first_name) > 0: + name = f"{self.first_name[0]}. {name_parts[0]}" return name def clean_club_name(self): From 1019c208903dd9c6ada58e5c5560653d2c460b5c Mon Sep 17 00:00:00 2001 From: Razmig Sarkissian Date: Tue, 23 Sep 2025 20:00:42 +0200 Subject: [PATCH 3/9] Fix fee calculation for tournament registration Correctly calculate fee based on minimum team size instead of current number of players --- tournaments/services/tournament_registration.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tournaments/services/tournament_registration.py b/tournaments/services/tournament_registration.py index db6c0d7..a8cba10 100644 --- a/tournaments/services/tournament_registration.py +++ b/tournaments/services/tournament_registration.py @@ -176,8 +176,8 @@ class RegistrationCartManager: players = self.session.get('registration_cart_players', []), entry_fee = tournament.entry_fee if entry_fee is not None and entry_fee > 0 and tournament.enable_online_payment: + fee = entry_fee * tournament.minimum_player_per_team players = self.session.get('registration_cart_players', []) - fee = entry_fee * len(players) club_members = sum(1 for player in players if player.get('club_member', False)) if tournament.club_member_fee_deduction is not None: return fee - club_members * tournament.club_member_fee_deduction From 7709409a63737729d5cdd0b543fbeeeb1ac48071 Mon Sep 17 00:00:00 2001 From: Razmig Sarkissian Date: Tue, 23 Sep 2025 20:04:51 +0200 Subject: [PATCH 4/9] Fix tournament cart fee calculation logic --- tournaments/services/tournament_registration.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tournaments/services/tournament_registration.py b/tournaments/services/tournament_registration.py index a8cba10..31a4b75 100644 --- a/tournaments/services/tournament_registration.py +++ b/tournaments/services/tournament_registration.py @@ -173,11 +173,10 @@ class RegistrationCartManager: except Tournament.DoesNotExist: return 0 - players = self.session.get('registration_cart_players', []), + players = self.session.get('registration_cart_players', []) entry_fee = tournament.entry_fee if entry_fee is not None and entry_fee > 0 and tournament.enable_online_payment: fee = entry_fee * tournament.minimum_player_per_team - players = self.session.get('registration_cart_players', []) club_members = sum(1 for player in players if player.get('club_member', False)) if tournament.club_member_fee_deduction is not None: return fee - club_members * tournament.club_member_fee_deduction From e6a626814335888d899ed8119bd7b3a9bb2d229d Mon Sep 17 00:00:00 2001 From: Razmig Sarkissian Date: Tue, 23 Sep 2025 20:08:01 +0200 Subject: [PATCH 5/9] Fix tournament registration fee calculation Correctly calculate entry fee based on number of registered players instead of minimum team size --- tournaments/services/tournament_registration.py | 2 +- tournaments/views.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tournaments/services/tournament_registration.py b/tournaments/services/tournament_registration.py index 31a4b75..1e8630b 100644 --- a/tournaments/services/tournament_registration.py +++ b/tournaments/services/tournament_registration.py @@ -176,7 +176,7 @@ class RegistrationCartManager: players = self.session.get('registration_cart_players', []) entry_fee = tournament.entry_fee if entry_fee is not None and entry_fee > 0 and tournament.enable_online_payment: - fee = entry_fee * tournament.minimum_player_per_team + fee = entry_fee * len(players) club_members = sum(1 for player in players if player.get('club_member', False)) if tournament.club_member_fee_deduction is not None: return fee - club_members * tournament.club_member_fee_deduction diff --git a/tournaments/views.py b/tournaments/views.py index 2fc077f..41226ba 100644 --- a/tournaments/views.py +++ b/tournaments/views.py @@ -1832,7 +1832,7 @@ def handle_add_player_request(request, tournament, cart_manager, context): # Refresh cart data cart_data = cart_manager.get_cart_data() context['current_players'] = cart_data['players'] - + context['cart_data'] = cart_data context['team_form'] = TournamentRegistrationForm(initial={ 'email': request.user.email if request.user.is_authenticated else '', 'mobile_number': cart_data.get('mobile_number', '') @@ -1864,6 +1864,7 @@ def handle_remove_player_request(request, tournament, cart_manager, context): # Refresh cart data cart_data = cart_manager.get_cart_data() context['current_players'] = cart_data['players'] + context['cart_data'] = cart_data # Update the add player form based on the new state if not cart_data['players'] and request.user.is_authenticated: From ad6139852de4144dd6117ddf6fd3df1398001479 Mon Sep 17 00:00:00 2001 From: Razmig Sarkissian Date: Tue, 23 Sep 2025 20:16:47 +0200 Subject: [PATCH 6/9] 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 --- tournaments/models/player_registration.py | 4 +++- tournaments/models/round.py | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/tournaments/models/player_registration.py b/tournaments/models/player_registration.py index 5c8cdf6..81879bd 100644 --- a/tournaments/models/player_registration.py +++ b/tournaments/models/player_registration.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(" ") diff --git a/tournaments/models/round.py b/tournaments/models/round.py index e776592..2379a8c 100644 --- a/tournaments/models/round.py +++ b/tournaments/models/round.py @@ -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 From 68750810972d4ec4f2ec2fde9ec29539d2d709b9 Mon Sep 17 00:00:00 2001 From: Razmig Sarkissian Date: Tue, 23 Sep 2025 20:31:12 +0200 Subject: [PATCH 7/9] Fix double butterfly mode condition for rounds count --- tournaments/models/round.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tournaments/models/round.py b/tournaments/models/round.py index 2379a8c..65dda76 100644 --- a/tournaments/models/round.py +++ b/tournaments/models/round.py @@ -113,7 +113,7 @@ class Round(TournamentSubModel): 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: + if double_butterfly_mode and self.tournament.rounds.filter(parent=None).count() < 3: short_names = False matches = self.matches.filter(disabled=False).order_by('index') if len(matches) == 0: From 9a3f92306d5354c32c0fa263ccaa29ee7dee1e40 Mon Sep 17 00:00:00 2001 From: Razmig Sarkissian Date: Wed, 24 Sep 2025 08:45:07 +0200 Subject: [PATCH 8/9] Replace timezone.localtime with local planned start date method --- tournaments/models/tournament.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tournaments/models/tournament.py b/tournaments/models/tournament.py index 384827c..7472d8d 100644 --- a/tournaments/models/tournament.py +++ b/tournaments/models/tournament.py @@ -2212,7 +2212,7 @@ class Tournament(BaseModel): # Group matches by hour matches_by_hour = {} for match in matches_by_day[selected_day]: - local_time = timezone.localtime(match.planned_start_date) + local_time = match.local_planned_start_date() hour_key = local_time.strftime('%H:%M') if hour_key not in matches_by_hour: From 33f170dd3e836f72fc1f4010f01fc67c1f0d48d6 Mon Sep 17 00:00:00 2001 From: Razmig Sarkissian Date: Wed, 24 Sep 2025 08:48:02 +0200 Subject: [PATCH 9/9] Replace timezone.localtime with local_planned_start_date method --- tournaments/models/tournament.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tournaments/models/tournament.py b/tournaments/models/tournament.py index 7472d8d..036cb98 100644 --- a/tournaments/models/tournament.py +++ b/tournaments/models/tournament.py @@ -2146,7 +2146,7 @@ class Tournament(BaseModel): for match in planned_matches: # Convert to local time zone - local_date = timezone.localtime(match.planned_start_date) + local_date = match.local_planned_start_date() day_key = local_date.date() days.add(day_key) @@ -2171,7 +2171,7 @@ class Tournament(BaseModel): # Group matches by hour matches_by_hour = {} for match in matches_by_day[selected_day]: - local_time = timezone.localtime(match.planned_start_date) + local_time = match.local_planned_start_date() hour_key = local_time.strftime('%H:%M') if hour_key not in matches_by_hour: