@ -2,6 +2,7 @@ from django.core.mail import EmailMessage
from enum import Enum
from enum import Enum
from . . models . enums import RegistrationStatus
from . . models . enums import RegistrationStatus
from . . models . tournament import TeamSortingType
from . . models . tournament import TeamSortingType
from django . utils import timezone
class TeamEmailType ( Enum ) :
class TeamEmailType ( Enum ) :
REGISTERED = " registered "
REGISTERED = " registered "
@ -515,13 +516,85 @@ class TournamentEmailService:
# For unpaid teams, add payment instructions
# For unpaid teams, add payment instructions
payment_info = [
payment_info = [
" \n \n ⚠️ Paiement des frais d ' inscription requis " ,
" \n \n ⚠️ Paiement des frais d ' inscription requis " ,
f " Les frais d ' inscription de { tournament . entry_fee } € par joueur doivent être payés pour confirmer votre participation. " ,
f " Les frais d ' inscription de { tournament . entry_fee : .2f } € par joueur doivent être payés pour confirmer votre participation. " ,
" Vous pouvez effectuer le paiement en vous connectant à votre compte Padel Club. " ,
" Vous pouvez effectuer le paiement en vous connectant à votre compte Padel Club. " ,
f " Lien pour payer: https://padelclub.app/tournament/ { tournament . id } /info "
f " Lien pour payer: https://padelclub.app/tournament/ { tournament . id } /info "
]
]
return " \n " . join ( payment_info )
return " \n " . join ( payment_info )
@staticmethod
def send_payment_confirmation ( team_registration , payment ) :
"""
Send a payment confirmation email to team members
Args :
team_registration : The team registration
payment : The payment details from Stripe
"""
tournament = team_registration . tournament
player_registrations = team_registration . players_sorted_by_rank
# Calculate payment amount
payment_amount = None
if payment and ' amount ' in payment :
# Convert cents to euros
payment_amount = payment [ ' amount ' ] / 100
if payment_amount is None :
payment_amount = tournament . team_fee ( )
for player in player_registrations :
if not player . email or not player . registered_online :
continue
tournament_details_str = tournament . build_tournament_details_str ( )
other_player = team_registration . get_other_player ( player ) if len ( player_registrations ) > 1 else None
body_parts = [
" Bonjour, \n \n " ,
f " Votre paiement pour le tournoi { tournament_details_str } , prévu le { tournament . formatted_start_date ( ) } au club { tournament . event . club . name } a été reçu avec succès. "
]
# Add information about the other player if available
if other_player :
body_parts . append (
f " \n \n Vous êtes inscrit avec { other_player . name ( ) } , n ' oubliez pas de prévenir votre partenaire de la confirmation du paiement. "
)
# Add payment details
body_parts . append (
f " \n \n Montant payé : { payment_amount : .2f } € "
)
payment_date = timezone . now ( ) . strftime ( " %d / % m/ % Y " )
body_parts . append (
f " \n Date du paiement : { payment_date } "
)
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 } " )
if tournament . team_sorting == TeamSortingType . RANK :
cloture_date = tournament . local_registration_federal_limit ( ) . strftime ( " %d / % m/ % Y à % H: % M " )
loc = " "
if cloture_date is not None :
loc = f " , prévu le { cloture_date } "
body_parts . append ( f " \n \n Attention, la sélection définitive se fera par poids d ' équipe à la clôture des inscriptions { loc } . " )
body_parts . extend ( [
f " \n \n { TournamentEmailService . _format_umpire_contact ( tournament ) } " ,
" \n \n Ceci est un e-mail automatique, veuillez ne pas y répondre. "
] )
email_body = " " . join ( body_parts )
email_subject = TournamentEmailService . email_subject ( tournament , " Confirmation de paiement " )
TournamentEmailService . _send_email ( player . email , email_subject , email_body )
@staticmethod
@staticmethod
def send_refund_confirmation ( tournament , team_registration , refund_details ) :
def send_refund_confirmation ( tournament , team_registration , refund_details ) :
"""
"""
@ -562,7 +635,7 @@ class TournamentEmailService:
# Add refund details
# Add refund details
body_parts . append (
body_parts . append (
f " \n \n Montant remboursé : { refund_amount } € par joueur "
f " \n \n Montant remboursé : { refund_amount : .2f } € "
)
)
refund_date = timezone . now ( ) . strftime ( " %d / % m/ % Y " )
refund_date = timezone . now ( ) . strftime ( " %d / % m/ % Y " )