feat(kfet): Change l'adresse utilisée pour envoyer les mails de négatif

This commit is contained in:
Tom Hubrecht 2023-06-15 12:56:30 +02:00
parent f97d339a1c
commit a0bde75f50
2 changed files with 15 additions and 8 deletions

View file

@ -207,7 +207,8 @@ MAIL_DATA = {
},
"rappels": {"FROM": "Le BdA <bda@ens.fr>", "REPLYTO": "Le BdA <bda@ens.fr>"},
"rappel_negatif": {
"FROM": "La K-Fêt <k-fet@ens.fr>",
"FROM": "La K-Fêt <chefs-k-fet@ens.fr>",
"REPLYTO": "La K-Fêt <chefs-k-fet@ens.fr>",
},
"revente": {
"FROM": "BdA-Revente <bda-revente@ens.fr>",

View file

@ -2,7 +2,7 @@ import re
from django.conf import settings
from django.contrib.auth.models import User
from django.core.mail import send_mail
from django.core.mail import EmailMessage
from django.core.validators import RegexValidator
from django.db import models, transaction
from django.db.models import F
@ -298,10 +298,11 @@ class AccountNegative(models.Model):
"""
Envoie un mail de rappel signalant que la personne est en négatif.
"""
# On envoie le mail
send_mail(
"Compte K-Psul négatif",
loader.render_to_string(
mail_data = settings.MAIL_DATA["rappel_negatif"]
email = EmailMessage(
subject="Compte K-Psul négatif",
body=loader.render_to_string(
"kfet/mails/rappel.txt",
context={
"account": self.account,
@ -309,9 +310,14 @@ class AccountNegative(models.Model):
"start_date": self.start,
},
),
settings.MAIL_DATA["rappel_negatif"]["FROM"],
[self.account.email],
from_email=mail_data["FROM"],
to=[self.account.email],
reply_to=[mail_data["REPLYTO"]],
)
# On envoie le mail
email.send()
# On enregistre le fait que l'envoi a bien eu lieu
self.last_rappel = timezone.now()
self.save()