diff --git a/apps/participation/templates/participation/mails/team_not_validated.html b/apps/participation/templates/participation/mails/team_not_validated.html
new file mode 100644
index 0000000..865bc0c
--- /dev/null
+++ b/apps/participation/templates/participation/mails/team_not_validated.html
@@ -0,0 +1,22 @@
+
+
+
+
+ Équipe non validée – Correspondances des Jeunes Mathématicien·ne·s
+
+
+Bonjour,
+
+Maleureusement, votre équipe « {{ team.name }} » ({{ team.trigram }}) n'a pas été validée. Veuillez vérifier que vos autorisations
+de droit à l'image sont correctes. Les organisateurs vous adressent ce message :
+
+{{ message }}
+
+N'hésitez pas à nous contacter à l'adresse contact@correspondances-maths.fr
+pour plus d'informations.
+
+Cordialement,
+
+Le comité d'organisation des Correspondances des Jeunes Mathématicien·ne·s
+
+
diff --git a/apps/participation/templates/participation/mails/team_not_validated.txt b/apps/participation/templates/participation/mails/team_not_validated.txt
new file mode 100644
index 0000000..e3d751a
--- /dev/null
+++ b/apps/participation/templates/participation/mails/team_not_validated.txt
@@ -0,0 +1,12 @@
+Bonjour,
+
+Maleureusement, votre équipe « {{ team.name }} » ({{ team.trigram }}) n'a pas été validée. Veuillez vérifier que vos
+autorisations de droit à l'image sont correctes. Les organisateurs vous adressent ce message :
+
+{{ message }}
+
+N'hésitez pas à nous contacter à l'adresse contact@correspondances-maths.fr pour plus d'informations.
+
+Cordialement,
+
+Le comité d'organisation des Correspondances des Jeunes Mathématicien·ne·s
diff --git a/apps/participation/templates/participation/mails/team_validated.html b/apps/participation/templates/participation/mails/team_validated.html
new file mode 100644
index 0000000..55df040
--- /dev/null
+++ b/apps/participation/templates/participation/mails/team_validated.html
@@ -0,0 +1,20 @@
+
+
+
+
+ Équipe validée – Correspondances des Jeunes Mathématicien·ne·s
+
+
+Bonjour,
+
+Félicitations ! Votre équipe « {{ team.name }} » ({{ team.trigram }}) est désormais validée ! Vous êtes désormais apte à travailler sur
+votre problème. Lorsque les Correspondances auront débutées, vous pourrez soumettre votre vidéo sur la plateforme d'inscription.
+Les organisateurs vous adressent ce message :
+
+{{ message }}
+
+Cordialement,
+
+Le comité d'organisation des Correspondances des Jeunes Mathématicien·ne·s
+
+
diff --git a/apps/participation/templates/participation/mails/team_validated.txt b/apps/participation/templates/participation/mails/team_validated.txt
new file mode 100644
index 0000000..07f4cee
--- /dev/null
+++ b/apps/participation/templates/participation/mails/team_validated.txt
@@ -0,0 +1,12 @@
+Bonjour,
+
+Félicitations ! Votre équipe « {{ team.name }} » ({{ team.trigram }}) est désormais validée ! Vous êtes désormais apte à travailler sur
+votre problème. Lorsque les Correspondances auront débutées, vous pourrez soumettre votre vidéo sur la plateforme d'inscription.
+
+Les organisateurs vous adressent ce message :
+
+{{ message }}
+
+Cordialement,
+
+Le comité d'organisation des Correspondances des Jeunes Mathématicien·ne·s
diff --git a/apps/participation/views.py b/apps/participation/views.py
index 381367a..fff0248 100644
--- a/apps/participation/views.py
+++ b/apps/participation/views.py
@@ -1,6 +1,9 @@
+import os
from io import BytesIO
from zipfile import ZipFile
+from django.core.mail import send_mail
+
from corres2math.lists import get_sympa_client
from django.contrib.auth.mixins import LoginRequiredMixin
from django.core.exceptions import PermissionDenied
@@ -152,9 +155,21 @@ 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("[Corres2math] Équipe validée", mail_plain, None,
+ [f"equipe-{self.object.trigram.lower()}@{os.getenv('SYMPA_HOST', 'localhost')}"],
+ 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)
+ send_mail("[Corres2math] Équipe non validée", mail_plain, None,
+ [f"equipe-{self.object.trigram.lower()}@{os.getenv('SYMPA_HOST', 'localhost')}"],
+ html_message=mail_html)
else:
form.add_error(None, _("You must specify if you validate the registration or not."))
return self.form_invalid(form)