|
|
|
@ -12,8 +12,6 @@ import requests |
|
|
|
from tournaments.services.email_service import TournamentEmailService |
|
|
|
from tournaments.services.email_service import TournamentEmailService |
|
|
|
from tournaments.models import PlayerDataSource |
|
|
|
from tournaments.models import PlayerDataSource |
|
|
|
|
|
|
|
|
|
|
|
tournament_deletion_in_progress = set() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def generate_unique_code(): |
|
|
|
def generate_unique_code(): |
|
|
|
characters = string.ascii_lowercase + string.digits |
|
|
|
characters = string.ascii_lowercase + string.digits |
|
|
|
while True: |
|
|
|
while True: |
|
|
|
@ -65,6 +63,8 @@ def send_discord_message(webhook_url, content): |
|
|
|
def unregister_team(sender, instance, **kwargs): |
|
|
|
def unregister_team(sender, instance, **kwargs): |
|
|
|
team_registration = instance |
|
|
|
team_registration = instance |
|
|
|
tournament = instance.tournament |
|
|
|
tournament = instance.tournament |
|
|
|
|
|
|
|
if tournament.is_deleted is True: |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
|
|
# Create unregistered player records and track captain/other player |
|
|
|
# Create unregistered player records and track captain/other player |
|
|
|
captain = None |
|
|
|
captain = None |
|
|
|
@ -83,16 +83,8 @@ def unregister_team(sender, instance, **kwargs): |
|
|
|
other_player |
|
|
|
other_player |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
@receiver(post_delete, sender=TeamRegistration) |
|
|
|
|
|
|
|
def handle_waiting_list(sender, instance, **kwargs): |
|
|
|
|
|
|
|
team_registration = instance |
|
|
|
|
|
|
|
tournament = team_registration.tournament |
|
|
|
|
|
|
|
global tournament_deletion_in_progress |
|
|
|
|
|
|
|
print('post_delete TeamRegistration', tournament_deletion_in_progress) |
|
|
|
|
|
|
|
if tournament.id in tournament_deletion_in_progress: |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
first_waiting_list_team = tournament.first_waiting_list_team() |
|
|
|
first_waiting_list_team = tournament.first_waiting_list_team() |
|
|
|
|
|
|
|
print("first_waiting_list_team", first_waiting_list_team) |
|
|
|
|
|
|
|
|
|
|
|
# Handle waiting list notifications |
|
|
|
# Handle waiting list notifications |
|
|
|
if first_waiting_list_team: |
|
|
|
if first_waiting_list_team: |
|
|
|
@ -111,18 +103,13 @@ def handle_waiting_list(sender, instance, **kwargs): |
|
|
|
waiting_other_player |
|
|
|
waiting_other_player |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
@receiver(post_delete, sender=Tournament) |
|
|
|
@receiver(post_save, sender=Tournament) |
|
|
|
def tournament_deletion(sender, instance, **kwargs): |
|
|
|
|
|
|
|
global tournament_deletion_in_progress |
|
|
|
|
|
|
|
tournament_deletion_in_progress.discard(instance.id) |
|
|
|
|
|
|
|
print('post tournament_deletion_in_progress', tournament_deletion_in_progress) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@receiver(pre_delete, sender=Tournament) |
|
|
|
|
|
|
|
def notify_players_of_tournament_cancellation(sender, instance, **kwargs): |
|
|
|
def notify_players_of_tournament_cancellation(sender, instance, **kwargs): |
|
|
|
tournament = instance |
|
|
|
tournament = instance |
|
|
|
global tournament_deletion_in_progress |
|
|
|
|
|
|
|
tournament_deletion_in_progress.add(instance.id) |
|
|
|
if tournament.is_deleted is False: |
|
|
|
print('pre tournament_deletion_in_progress', tournament_deletion_in_progress) |
|
|
|
return |
|
|
|
|
|
|
|
|
|
|
|
# Get all team registrations |
|
|
|
# Get all team registrations |
|
|
|
team_registrations = tournament.teamregistration_set.all() |
|
|
|
team_registrations = tournament.teamregistration_set.all() |
|
|
|
|
|
|
|
|
|
|
|
|