Laurent 2 months ago
commit 409777f6b6
  1. 8
      tournaments/models/player_registration.py
  2. 5
      tournaments/models/round.py
  3. 6
      tournaments/models/tournament.py
  4. 5
      tournaments/services/tournament_registration.py
  5. 3
      tournaments/views.py

@ -85,10 +85,14 @@ 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.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(" ")
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):

@ -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.filter(parent=None).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

@ -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:
@ -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:

@ -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', [])
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

@ -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:

Loading…
Cancel
Save