@ -14,11 +14,17 @@ class TournamentEmailService:
< / html >
< / html >
"""
"""
@staticmethod
def email_subject ( tournament , topic ) :
base_subject = f " [ { tournament . build_tournament_type_str ( ) } ] [ { tournament . formatted_start_date ( ) } ] " + topic
return base_subject
@staticmethod
@staticmethod
def send_registration_confirmation ( request , tournament , team_registration , waiting_list_position ) :
def send_registration_confirmation ( request , tournament , team_registration , waiting_list_position ) :
tournament_details_str = tournament . build_tournament_details_str ( )
tournament_details_str = tournament . build_tournament_details_str ( )
email_subject = TournamentEmailService . _build_email_subject (
email_subject = TournamentEmailService . _build_email_subject (
tournament ,
tournament_details_str ,
tournament_details_str ,
waiting_list_position
waiting_list_position
)
)
@ -41,11 +47,12 @@ class TournamentEmailService:
email . send ( )
email . send ( )
@staticmethod
@staticmethod
def _build_email_subject ( tournament_details_str , waiting_list_position ) :
def _build_email_subject ( tournament , tournament_details_str , waiting_list_position ) :
base_subject = f " Confirmation d ' inscription au tournoi { tournament_details_str } "
if waiting_list_position > = 0 :
if waiting_list_position > = 0 :
base_subject = f " En liste d ' attente du tournoi { tournament_details_str } "
base_subject = " En liste d ' attente du tournoi "
return base_subject
else :
base_subject = " Confirmation d ' inscription au tournoi "
return TournamentEmailService . email_subject ( tournament , base_subject )
@staticmethod
@staticmethod
def _build_email_body ( request , tournament , team_registration , tournament_details_str , waiting_list_position ) :
def _build_email_body ( request , tournament , team_registration , tournament_details_str , waiting_list_position ) :
@ -68,7 +75,7 @@ class TournamentEmailService:
body_parts . extend ( [
body_parts . extend ( [
f " \n Date d ' inscription: { inscription_date } " ,
f " \n Date d ' inscription: { inscription_date } " ,
f " \n Équipe inscrite: { team_members_str } " ,
f " \n Équipe inscrite: { team_members_str } " ,
f " \n Le tournoi commencera le { tournament . start_date . strftime ( ' %d / % m/ % Y ' ) } au club { tournament . event . club . name } " ,
f " \n Le tournoi commencera le { tournament . formatted_ start_date( ) } au club { tournament . event . club . name } " ,
f " \n Voir les { absolute_url } " ,
f " \n Voir les { absolute_url } " ,
" \n Pour toute question, veuillez contacter votre juge-arbitre. Si vous n ' êtes pas à l ' origine de cette inscription, merci de le contacter rapidement. " ,
" \n Pour toute question, veuillez contacter votre juge-arbitre. Si vous n ' êtes pas à l ' origine de cette inscription, merci de le contacter rapidement. " ,
f " \n { tournament . event . creator . full_name ( ) } \n { tournament . event . creator . email } " ,
f " \n { tournament . event . creator . full_name ( ) } \n { tournament . event . creator . email } " ,
@ -82,7 +89,7 @@ class TournamentEmailService:
def send_unregistration_confirmation ( captain , tournament , other_player ) :
def send_unregistration_confirmation ( captain , tournament , other_player ) :
tournament_details_str = tournament . build_tournament_details_str ( )
tournament_details_str = tournament . build_tournament_details_str ( )
email_subject = f " Désistement du tournoi { tournament_details_str } "
email_subject = TournamentEmailService . email_subject ( tournament , " Désistement du tournoi " )
email_body = TournamentEmailService . _build_unregistration_email_body (
email_body = TournamentEmailService . _build_unregistration_email_body (
tournament ,
tournament ,
captain ,
captain ,
@ -119,9 +126,8 @@ class TournamentEmailService:
@staticmethod
@staticmethod
def send_out_of_waiting_list_confirmation ( captain , tournament , other_player ) :
def send_out_of_waiting_list_confirmation ( captain , tournament , other_player ) :
tournament_details_str = tournament . build_tournament_details_str ( )
tournament_details_str = tournament . build_tournament_details_str ( )
email_subject = TournamentEmailService . email_subject ( tournament , " Participation au tournoi " )
email_subject = f " Participation au tournoi { tournament_details_str } "
email_body = TournamentEmailService . _build_out_of_waiting_list_email_body (
email_body = TournamentEmailService . _buil_out_of_waiting_list_email_body (
tournament ,
tournament ,
captain ,
captain ,
tournament_details_str ,
tournament_details_str ,
@ -138,7 +144,7 @@ class TournamentEmailService:
email . send ( )
email . send ( )
if other_player . email is not None :
if other_player . email is not None :
email_body = TournamentEmailService . _buil_out_of_waiting_list_email_body (
email_body = TournamentEmailService . _build _out_of_waiting_list_email_body (
tournament ,
tournament ,
other_player ,
other_player ,
tournament_details_str ,
tournament_details_str ,
@ -158,7 +164,7 @@ class TournamentEmailService:
def _build_unregistration_email_body ( tournament , captain , tournament_details_str , other_player ) :
def _build_unregistration_email_body ( tournament , captain , tournament_details_str , other_player ) :
body_parts = [
body_parts = [
" Bonjour, \n \n " ,
" 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 "
f " Votre inscription au tournoi { tournament_details_str } , prévu le { tournament . formatted_ start_date( ) } au club { tournament . event . club . name } a été annulée "
]
]
if other_player is not None :
if other_player is not None :
@ -166,9 +172,17 @@ class TournamentEmailService:
f " \n \n Vous étiez inscrit avec { other_player . name ( ) } , n ' oubliez pas de prévenir votre partenaire. "
f " \n \n Vous étiez inscrit avec { other_player . name ( ) } , n ' oubliez pas de prévenir votre partenaire. "
)
)
absolute_url = f " https://padelclub.app/tournament/ { tournament . id } /info "
link_text = " informations sur le tournoi "
absolute_url = f ' <a href= " { absolute_url } " > { link_text } </a> '
body_parts . append (
f " \n \n Voir les { absolute_url } " ,
)
body_parts . extend ( [
body_parts . extend ( [
" \n \n Pour toute question, veuillez contacter votre juge-arbitre. "
" \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. " ,
" Si vous n ' êtes pas à l ' origine de cette dés inscription, merci de le contacter rapidement. " ,
f " \n { tournament . event . creator . full_name ( ) } \n { tournament . event . creator . email } " ,
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. "
" \n \n Ceci est un e-mail automatique, veuillez ne pas y répondre. "
] )
] )
@ -176,14 +190,14 @@ class TournamentEmailService:
return " " . join ( body_parts )
return " " . join ( body_parts )
@staticmethod
@staticmethod
def _buil_out_of_waiting_list_email_body ( tournament , captain , tournament_details_str , other_player ) :
def _build _out_of_waiting_list_email_body ( tournament , captain , tournament_details_str , other_player ) :
body_parts = [
body_parts = [
" Bonjour, \n \n " ,
" 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 } "
f " Suite au désistement d ' une paire, vous êtes maintenant inscrit au tournoi { tournament_details_str } , prévu le { tournament . formatted_ start_date( ) } au club { tournament . event . club . name } "
]
]
absolute_url = f " https://padelclub.app/tournament/ { tournament . id } /info "
absolute_url = f " https://padelclub.app/tournament/ { tournament . id } /info "
link_text = " informations sur le tournoi"
link_text = " accéder au tournoi"
absolute_url = f ' <a href= " { absolute_url } " > { link_text } </a> '
absolute_url = f ' <a href= " { absolute_url } " > { link_text } </a> '
if other_player is not None :
if other_player is not None :
@ -192,8 +206,9 @@ class TournamentEmailService:
)
)
body_parts . append (
body_parts . append (
" \n Si vous n' êtes plus disponible pour participer à ce tournoi, cliquez sur ce lien ou contactez rapidement le juge-arbitre. "
" \n \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 } "
f " \n { absolute_url } "
" \n Pour vous désinscrire en ligne vous devez avoir un compte Padel Club. "
)
)
body_parts . extend ( [
body_parts . extend ( [
@ -206,8 +221,7 @@ class TournamentEmailService:
@staticmethod
@staticmethod
def send_tournament_cancellation_notification ( player , tournament , other_player ) :
def send_tournament_cancellation_notification ( player , tournament , other_player ) :
tournament_details_str = tournament . build_tournament_details_str ( )
tournament_details_str = tournament . build_tournament_details_str ( )
email_subject = TournamentEmailService . email_subject ( tournament , " Annulation du tournoi " )
email_subject = f " Annulation du tournoi { tournament_details_str } "
email_body = TournamentEmailService . _build_tournament_cancellation_email_body (
email_body = TournamentEmailService . _build_tournament_cancellation_email_body (
tournament ,
tournament ,
player ,
player ,
@ -228,7 +242,7 @@ class TournamentEmailService:
def _build_tournament_cancellation_email_body ( tournament , player , tournament_details_str , other_player ) :
def _build_tournament_cancellation_email_body ( tournament , player , tournament_details_str , other_player ) :
body_parts = [
body_parts = [
" Bonjour, \n \n " ,
" 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. "
f " Le tournoi { tournament_details_str } , prévu le { tournament . formatted_ start_date( ) } au club { tournament . event . club . name } a été annulé par le juge-arbitre. "
]
]
if other_player is not None :
if other_player is not None :