From 0129e32643ae2966c8e13b22c5b29224124d4b42 Mon Sep 17 00:00:00 2001 From: Emmy D'Anello Date: Tue, 30 Apr 2024 20:29:52 +0200 Subject: [PATCH] Messages in team validation mails now contains line breaks Signed-off-by: Emmy D'Anello --- participation/views.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/participation/views.py b/participation/views.py index 8af0777..88509d5 100644 --- a/participation/views.py +++ b/participation/views.py @@ -259,17 +259,20 @@ class TeamDetailView(LoginRequiredMixin, FormMixin, ProcessFormView, DetailView) payment = Payment.objects.get(registrations=registration, final=False) else: payment = None - mail_context = dict(domain=domain, registration=registration, team=self.object, payment=payment, - message=form.cleaned_data["message"]) - mail_plain = render_to_string("participation/mails/team_validated.txt", mail_context) - mail_html = render_to_string("participation/mails/team_validated.html", mail_context) + mail_context_plain = dict(domain=domain, registration=registration, team=self.object, payment=payment, + message=form.cleaned_data["message"]) + mail_context_html = dict(domain=domain, registration=registration, team=self.object, payment=payment, + message=form.cleaned_data["message"].replace('\n', '
')) + mail_plain = render_to_string("participation/mails/team_validated.txt", mail_context_plain) + mail_html = render_to_string("participation/mails/team_validated.html", mail_context_html) registration.user.email_user("[TFJM²] Équipe validée", mail_plain, html_message=mail_html) elif "invalidate" in self.request.POST: self.object.participation.valid = None self.object.participation.save() - mail_context = dict(team=self.object, message=form.cleaned_data["message"]) - mail_plain = render_to_string("participation/mails/team_not_validated.txt", mail_context) - mail_html = render_to_string("participation/mails/team_not_validated.html", mail_context) + mail_context_plain = dict(team=self.object, message=form.cleaned_data["message"]) + mail_context_html = dict(team=self.object, message=form.cleaned_data["message"].replace('\n', '
')) + mail_plain = render_to_string("participation/mails/team_not_validated.txt", mail_context_plain) + mail_html = render_to_string("participation/mails/team_not_validated.html", mail_context_html) send_mail("[TFJM²] Équipe non validée", mail_plain, None, [self.object.email], html_message=mail_html) else: