@ -39,7 +39,8 @@ class TournamentEmailService:
return base_subject
@staticmethod
def _build_email_body ( request , tournament , team_registration , tournament_details_str , name_str , waiting_list_position ) :
def _build_email_body ( request , tournament , team_registration , tournament_details_str ,
name_str , waiting_list_position ) :
inscription_date = timezone . now ( ) . strftime ( " %d / % m/ % Y à % H: % M " )
team_members = [ player . name ( ) for player in team_registration . playerregistration_set . all ( ) ]
team_members_str = " et " . join ( team_members )
@ -66,13 +67,12 @@ class TournamentEmailService:
return " \n " . join ( body_parts )
@staticmethod
def send_unregistration_confirmation ( request , captain , tournament , other_player ) :
def send_unregistration_confirmation ( captain , tournament , other_player ) :
tournament_details_str = tournament . build_tournament_details_str ( )
name_str = tournament . build_name_details_str ( )
email_subject = f " Confirmation de désistement du tournoi { tournament_details_str } { name_str } "
email_body = TournamentEmailService . _build_unregistration_email_body (
request ,
tournament ,
captain ,
tournament_details_str ,
@ -87,14 +87,29 @@ class TournamentEmailService:
)
email . send ( )
if other_player . email is not None :
email_body = TournamentEmailService . _build_unregistration_email_body (
tournament ,
other_player ,
tournament_details_str ,
name_str ,
captain
)
email = EmailMessage (
subject = email_subject ,
body = email_body ,
to = [ other_player . email ]
)
email . send ( )
@staticmethod
def send_out_of_waiting_list_confirmation ( request , captain , tournament , other_player ) :
def send_out_of_waiting_list_confirmation ( captain , tournament , other_player ) :
tournament_details_str = tournament . build_tournament_details_str ( )
name_str = tournament . build_name_details_str ( )
email_subject = f " Participation au tournoi { tournament_details_str } { name_str } "
email_body = TournamentEmailService . _buil_out_of_waiting_list_email_body (
request ,
tournament ,
captain ,
tournament_details_str ,
@ -109,8 +124,25 @@ class TournamentEmailService:
)
email . send ( )
if other_player . email is not None :
email_body = TournamentEmailService . _buil_out_of_waiting_list_email_body (
tournament ,
other_player ,
tournament_details_str ,
name_str ,
captain
)
email = EmailMessage (
subject = email_subject ,
body = email_body ,
to = [ other_player . email ]
)
email . send ( )
@staticmethod
def _build_unregistration_email_body ( request , tournament , captain , tournament_details_str , name_str , other_player ) :
def _build_unregistration_email_body ( tournament , captain , tournament_details_str , name_str , other_player ) :
body_parts = [
" Bonjour, \n " ,
f " Votre inscription au tournoi { tournament_details_str } { name_str } , prévu le { tournament . start_date . strftime ( ' %d / % m/ % Y ' ) } au club { tournament . event . club . name } a été annulée "
@ -121,10 +153,6 @@ class TournamentEmailService:
f " \n \n Vous étiez inscrit avec { other_player . name ( ) } , n ' oubliez pas de prévenir votre partenaire. "
)
body_parts . extend ( [
f " \n \n Voir les informations du tournoi sur { request . build_absolute_uri ( f ' /tournament/ { tournament . id } / ' ) } " ,
] )
body_parts . extend ( [
" \n \n Pour toute question, veuillez contacter votre juge-arbitre. "
" Si vous n ' êtes pas à l ' origine de cette inscription, merci de le contacter rapidement. " ,
@ -135,21 +163,23 @@ class TournamentEmailService:
return " " . join ( body_parts )
@staticmethod
def _buil_out_of_waiting_list_email_body ( request , tournament , captain , tournament_details_str , name_str , other_player ) :
def _buil_out_of_waiting_list_email_body ( tournament , captain , tournament_details_str , name_str , other_player ) :
body_parts = [
" Bonjour, \n " ,
f " Suite au désistement d ' une paire, vous êtes maintenant inscrit au tournoi { tournament_details_str } { name_str } , prévu le { tournament . start_date . strftime ( ' %d / % m/ % Y ' ) } au club { tournament . event . club . name } "
]
unregister_url = reverse ( ' unregister-tournament ' , args = [ tournament . id ] )
# Make it an absolute URL by adding the domain
absolute_url = f " https://127.0.0.1:8000 { unregister_url } " # Replace with your domain
absolute_url = request . build_absolute_uri ( unregister_url )
if other_player is not None :
body_parts . append (
f " \n Voici le partenaire indiqué dans l ' inscription : { other_player . name ( ) } , n ' oubliez pas de le prévenir. "
)
body_parts . append (
" \n Si vous n ' êtes plus disponible pour participer à ce tournoi, cliquez sur ce lien ou contactez rapidement le juge-arbitre. "
f " \n { absolute_url } "