various fixes and improvements

sync
Laurent 8 months ago
parent 15231d9299
commit a0998299ee
  1. 6
      sync/views.py
  2. 8
      tournaments/models/match.py
  3. 2
      tournaments/models/team_registration.py
  4. 4
      tournaments/services/email_service.py
  5. 1
      tournaments/templates/tournaments/group_stages.html
  6. 2
      tournaments/views.py

@ -159,7 +159,11 @@ class SynchronizationApi(HierarchyApiView):
except Exception as e:
response_status = status.HTTP_400_BAD_REQUEST
print(f'OTHER exception on {model_operation} {model_name} : {str(e)}, type: {type(e)}, id: {data.get('id')}')
import traceback
tb = traceback.extract_tb(e.__traceback__)
file_name = tb[-1].filename
line_number = tb[-1].lineno
print(f'OTHER exception on {model_operation} {model_name} : {str(e)}, type: {type(e)}, id: {data.get('id')}, file: {file_name}, line: {line_number}')
message = str(e)
results.append({

@ -111,9 +111,9 @@ class Match(SideStoreModel):
previous_round = None
# Check if the next index is within the bounds of the rounds array
previous_round = self.round.tournament.round_set.filter(index=previous_index, parent = self.round.parent).first()
previous_round = self.round.tournament.rounds.filter(index=previous_index, parent = self.round.parent).first()
if previous_round is None and self.round.parent is not None:
previous_round = self.round.tournament.round_set.filter(id=self.round.parent.id).first()
previous_round = self.round.tournament.rounds.filter(id=self.round.parent.id).first()
return previous_round
return None
@ -133,7 +133,7 @@ class Match(SideStoreModel):
previous_round = self.get_loser_previous_round()
match = None
if previous_round:
matches = previous_round.match_set.all() # Retrieve the QuerySet
matches = previous_round.matches.all() # Retrieve the QuerySet
match_index = self.index * 2 + 1
if top == False:
match_index += 1
@ -254,7 +254,7 @@ class Match(SideStoreModel):
team = self.default_live_team(names)
teams.append(existing_team)
teams.append(team)
elif (self.round.parent is None and self.round.tournament.round_set.filter(parent__isnull=True, group_stage_loser_bracket=False).count() - 1 == self.round.index):
elif (self.round.parent is None and self.round.tournament.rounds.filter(parent__isnull=True, group_stage_loser_bracket=False).count() - 1 == self.round.index):
match_index_within_round = self.index - (int(2 ** self.round.index) - 1)
names = ["Qualifié", '']
team = self.default_live_team(names)

@ -281,7 +281,7 @@ class TeamRegistration(SideStoreModel):
return None
def has_registered_online(self):
for p in self.playerregistration_set.all():
for p in self.player_registrations.all():
if p.registered_online:
return True
return False

@ -418,7 +418,7 @@ class TournamentEmailService:
captain = None
other_player = None
for player in team.playerregistration_set.all():
for player in team.player_registrations.all():
if player.captain:
captain = player
else:
@ -428,7 +428,7 @@ class TournamentEmailService:
TournamentEmailService.notify(captain, other_player, tournament, message_type)
else:
# Notify both players separately if there is no captain or the captain is unavailable
players = list(team.playerregistration_set.all())
players = list(team.player_registrations.all())
if len(players) == 2:
first_player, second_player = players
TournamentEmailService.notify(first_player, second_player, tournament, message_type)

@ -4,7 +4,6 @@
{% block first_title %}{{ tournament.event.display_name }}{% endblock %}
{% block second_title %}{{ tournament.display_name }}{% endblock %}
{% block title_link %}{% url 'tournament' tournament.id %}{% endblock %}
{% if tournament.display_group_stages %}
{% block content %}
{% if tournament.display_group_stages %}

@ -938,7 +938,7 @@ def tournament_bracket(request, tournament_id):
else:
first_half_matches = list(matches) # Convert QuerySet to a list
if loser_final:
loser_matches = loser_final.match_set.all()
loser_matches = loser_final.matches.all()
if len(loser_matches) >= 1:
first_half_matches.append(loser_matches[0])

Loading…
Cancel
Save