@ -17,11 +17,9 @@ class TournamentEmailService:
@staticmethod
def send_registration_confirmation ( request , tournament , team_registration , waiting_list_position ) :
tournament_details_str = tournament . build_tournament_details_str ( )
name_str = tournament . build_name_details_str ( )
email_subject = TournamentEmailService . _build_email_subject (
tournament_details_str ,
name_str ,
waiting_list_position
)
@ -30,7 +28,6 @@ class TournamentEmailService:
tournament ,
team_registration ,
tournament_details_str ,
name_str ,
waiting_list_position
)
@ -44,15 +41,14 @@ class TournamentEmailService:
email . send ( )
@staticmethod
def _build_email_subject ( tournament_details_str , name_str , waiting_list_position ) :
base_subject = f " Confirmation d ' inscription au tournoi { tournament_details_str } { name_str } "
def _build_email_subject ( tournament_details_str , waiting_list_position ) :
base_subject = f " Confirmation d ' inscription au tournoi { tournament_details_str } "
if waiting_list_position > = 0 :
base_subject = f " En liste d ' attente du tournoi { tournament_details_str } { name_str } "
base_subject = f " En liste d ' attente du tournoi { tournament_details_str } "
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 , waiting_list_position ) :
inscription_date = team_registration . local_registration_date ( ) . 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 )
@ -61,9 +57,9 @@ class TournamentEmailService:
body_parts . append ( " Bonjour, \n " )
if waiting_list_position > = 0 :
body_parts . append ( f " Votre inscription en liste d ' attente du tournoi { tournament_details_str } { name_str } est confirmée." )
body_parts . append ( f " Votre inscription en liste d ' attente du tournoi { tournament_details_str } est confirmée. " )
else :
body_parts . append ( f " Votre inscription au tournoi { tournament_details_str } { name_str } est confirmée." )
body_parts . append ( f " Votre inscription au tournoi { tournament_details_str } est confirmée. " )
absolute_url = f " { request . build_absolute_uri ( f ' /tournament/ { tournament . id } / ' ) } "
link_text = " informations sur le tournoi "
@ -85,14 +81,12 @@ class TournamentEmailService:
@staticmethod
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_subject = f " Confirmation de désistement du tournoi { tournament_details_str } "
email_body = TournamentEmailService . _build_unregistration_email_body (
tournament ,
captain ,
tournament_details_str ,
name_str ,
other_player
)
@ -110,7 +104,6 @@ class TournamentEmailService:
tournament ,
other_player ,
tournament_details_str ,
name_str ,
captain
)
@ -126,14 +119,12 @@ class TournamentEmailService:
@staticmethod
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_subject = f " Participation au tournoi { tournament_details_str } "
email_body = TournamentEmailService . _buil_out_of_waiting_list_email_body (
tournament ,
captain ,
tournament_details_str ,
name_str ,
other_player
)
@ -151,7 +142,6 @@ class TournamentEmailService:
tournament ,
other_player ,
tournament_details_str ,
name_str ,
captain
)
@ -165,10 +155,10 @@ class TournamentEmailService:
email . send ( )
@staticmethod
def _build_unregistration_email_body ( tournament , captain , tournament_details_str , name_str , other_player ) :
def _build_unregistration_email_body ( tournament , captain , tournament_details_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 "
" Bonjour, \n \n ",
f " Votre inscription au tournoi { tournament_details_str } , prévu le { tournament . start_date . strftime ( ' %d / % m/ % Y ' ) } au club { tournament . event . club . name } a été annulée "
]
if other_player is not None :
@ -186,10 +176,10 @@ class TournamentEmailService:
return " " . join ( body_parts )
@staticmethod
def _buil_out_of_waiting_list_email_body ( tournament , captain , tournament_details_str , name_str , other_player ) :
def _buil_out_of_waiting_list_email_body ( tournament , captain , tournament_details_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 } "
" Bonjour, \n \n ",
f " Suite au désistement d ' une paire, vous êtes maintenant inscrit au tournoi { tournament_details_str } , prévu le { tournament . start_date . strftime ( ' %d / % m/ % Y ' ) } au club { tournament . event . club . name } "
]
absolute_url = f " https://padelclub.app/tournament/ { tournament . id } /info "
@ -212,3 +202,44 @@ class TournamentEmailService:
] )
return " " . join ( body_parts )
@staticmethod
def send_tournament_cancellation_notification ( player , tournament , other_player ) :
tournament_details_str = tournament . build_tournament_details_str ( )
email_subject = f " Annulation du tournoi { tournament_details_str } "
email_body = TournamentEmailService . _build_tournament_cancellation_email_body (
tournament ,
player ,
tournament_details_str ,
other_player
)
email = EmailMessage (
subject = email_subject ,
body = TournamentEmailService . _convert_newlines_to_html ( email_body ) ,
to = [ player . email ]
)
email . content_subtype = " html "
email . send ( )
@staticmethod
def _build_tournament_cancellation_email_body ( tournament , player , tournament_details_str , other_player ) :
body_parts = [
" Bonjour, \n \n " ,
f " Le tournoi { tournament_details_str } , prévu le { tournament . start_date . strftime ( ' %d / % m/ % Y ' ) } au club { tournament . event . club . name } a été annulé par le juge-arbitre. "
]
if other_player is not None :
body_parts . append (
f " \n Vous étiez inscrit avec { other_player . name ( ) } , n ' oubliez pas de prévenir votre partenaire. "
)
body_parts . extend ( [
" \n \n Pour toute question, veuillez contacter votre juge-arbitre: " ,
f " \n { tournament . event . creator . full_name ( ) } \n { tournament . event . creator . email } " ,
" \n \n Ceci est un e-mail automatique, veuillez ne pas y répondre. "
] )
return " " . join ( body_parts )