diff --git a/api/views.py b/api/views.py index 58ddee2..1f86b01 100644 --- a/api/views.py +++ b/api/views.py @@ -633,7 +633,8 @@ def resend_payment_email(request, team_registration_id): request, tournament, team_registration, - waiting_list_position=-1 + waiting_list_position=-1, + force_send=True ) return Response({ diff --git a/tournaments/services/email_service.py b/tournaments/services/email_service.py index accd0a4..bc0cf39 100644 --- a/tournaments/services/email_service.py +++ b/tournaments/services/email_service.py @@ -71,11 +71,11 @@ class TournamentEmailService: return base_subject @staticmethod - def send_registration_confirmation(request, tournament, team_registration, waiting_list_position): + def send_registration_confirmation(request, tournament, team_registration, waiting_list_position, force_send=False): if waiting_list_position >= 0: - TournamentEmailService.notify_team(team_registration, tournament, TeamEmailType.WAITING_LIST) + TournamentEmailService.notify_team(team_registration, tournament, TeamEmailType.WAITING_LIST, force_send) else: - TournamentEmailService.notify_team(team_registration, tournament, TeamEmailType.REGISTERED) + TournamentEmailService.notify_team(team_registration, tournament, TeamEmailType.REGISTERED, force_send) @staticmethod def _build_registration_confirmation_email_body(tournament, captain, tournament_details_str, other_player): @@ -515,9 +515,9 @@ class TournamentEmailService: return f"\n\n{warning_text}{action_text}{account_info}" @staticmethod - def notify(captain, other_player, tournament, message_type: TeamEmailType): + def notify(captain, other_player, tournament, message_type: TeamEmailType, force_send=False): print("TournamentEmailService.notify", captain.player_contact(), captain.registered_online, tournament, message_type) - if not captain or not captain.registered_online or not captain.player_contact(): + if not captain or (not captain.registered_online and not force_send) or not captain.player_contact(): return tournament_details_str = tournament.build_tournament_details_str() @@ -600,19 +600,19 @@ class TournamentEmailService: # print"TournamentEmailService._send_email", to, subject) @staticmethod - def notify_team(team, tournament, message_type: TeamEmailType): + def notify_team(team, tournament, message_type: TeamEmailType, force_send=False): # Notify both players separately if there is no captain or the captain is unavailable players = list(team.players_sorted_by_captain) if len(players) == 2: # print"TournamentEmailService.notify_team 2p", team) first_player, second_player = players - TournamentEmailService.notify(first_player, second_player, tournament, message_type) + TournamentEmailService.notify(first_player, second_player, tournament, message_type, force_send) if first_player.player_contact() != second_player.player_contact(): - TournamentEmailService.notify(second_player, first_player, tournament, message_type) + TournamentEmailService.notify(second_player, first_player, tournament, message_type, force_send) elif len(players) == 1: # print"TournamentEmailService.notify_team 1p", team) # If there's only one player, just send them the notification - TournamentEmailService.notify(players[0], None, tournament, message_type) + TournamentEmailService.notify(players[0], None, tournament, message_type, force_send) @staticmethod def notify_umpire(team, tournament, message_type):