Add force_send option to resend registration emails

main
Razmig Sarkissian 4 weeks ago
parent 005d8877e7
commit fcb2ef9549
  1. 3
      api/views.py
  2. 18
      tournaments/services/email_service.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({

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

Loading…
Cancel
Save