diff --git a/manuels/context_processors.py b/manuels/context_processors.py index dc80c56..aa216f7 100644 --- a/manuels/context_processors.py +++ b/manuels/context_processors.py @@ -1,5 +1,5 @@ -import os +from django.conf import settings def authorized_mails(request): - return {'authorized_mails': os.getenv('AUTHORIZED_MAILS', '').split(',')} + return {'authorized_mails': settings.AUTHORIZED_MAILS} diff --git a/manuels/models.py b/manuels/models.py index 6722e1e..7b2acb7 100644 --- a/manuels/models.py +++ b/manuels/models.py @@ -79,7 +79,25 @@ class Teacher(BaseModel): if reply_to: msg.reply_to = reply_to msg.attach_alternative( - render_to_string('manuels/email.html', {'link': link, 'teacher': self}), "text/html" + render_to_string('manuels/emails_link.html', {'link': link, 'teacher': self}), "text/html" + ) + msg.send() + + def send_confirmation(self, request): + dest = settings.LIBRARIAN_EMAILS + link = request.build_absolute_uri(reverse('home_page')) + msg = EmailMultiAlternatives( + subject="Gestion des manuels scolaires - Confirmation d'un coordonnateur", + body=f'Bonjour,\n' + f'{self.first_name} a confirmé ses listes sur {link}', + from_email=settings.SERVER_EMAIL, + to=dest, + ) + reply_to = [os.getenv('REPLY_TO')] + if reply_to: + msg.reply_to = reply_to + msg.attach_alternative( + render_to_string('manuels/emails_confirmation.html', {'link': link, 'teacher': self}), "text/html" ) msg.send() diff --git a/manuels/templates/manuels/confirm_teacher.html b/manuels/templates/manuels/confirm_teacher.html index 3ac300b..c30ec93 100644 --- a/manuels/templates/manuels/confirm_teacher.html +++ b/manuels/templates/manuels/confirm_teacher.html @@ -15,7 +15,7 @@
Êtes-vous certain·e de vouloir confirmer vos listes ? - Cette action est définitive : vous ne pourrez plus les modifier ensuite. + Cette action est définitive : vous ne ne serez plus en mesure de les modifier ensuite.