1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2025-08-16 18:50:07 +02:00

Update validate team mail with a payment reminder

Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
Emmy D'Anello
2024-02-24 09:56:57 +01:00
parent 6e35bdc0b3
commit 1d01376703
3 changed files with 65 additions and 21 deletions

View File

@@ -244,11 +244,18 @@ class TeamDetailView(LoginRequiredMixin, FormMixin, ProcessFormView, DetailView)
if "validate" in self.request.POST:
self.object.participation.valid = True
self.object.participation.save()
mail_context = dict(team=self.object, 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)
send_mail("[TFJM²] Équipe validée", mail_plain, None, [self.object.email], html_message=mail_html)
domain = Site.objects.first().domain
for registration in self.object.participants.all():
if registration.is_student and self.object.participation.tournament.amount:
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)
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()