forked from DGNum/gestioCOF
Utilise django_custommail
- On installe le package depuis le dépôt COF-Geek - On supprime tous les fichiers texte des mails - On charge dans la bdd les mails nécessaires au fonctionnement de GestioCOF - On supprime le modèle CustomMail obsolète de gestioncof
This commit is contained in:
parent
2d1a9d8ecb
commit
fe8f18ff78
19 changed files with 147 additions and 316 deletions
|
@ -14,7 +14,7 @@ from django.db import connection
|
|||
from django.core.mail import send_mail
|
||||
from django.template import Template, Context
|
||||
|
||||
from gestioncof.models import CofProfile, CustomMail
|
||||
from gestioncof.models import CofProfile
|
||||
|
||||
User = get_user_model()
|
||||
|
||||
|
@ -99,18 +99,3 @@ def unlock_tables(*models):
|
|||
return row
|
||||
|
||||
unlock_table = unlock_tables
|
||||
|
||||
|
||||
def send_custom_mail(to, shortname, context=None, from_email="cof@ens.fr"):
|
||||
if context is None:
|
||||
context = {}
|
||||
if isinstance(to, DjangoUser):
|
||||
context["nom"] = to.get_full_name()
|
||||
context["prenom"] = to.first_name
|
||||
to = to.email
|
||||
mail = CustomMail.objects.get(shortname=shortname)
|
||||
template = Template(mail.content)
|
||||
message = template.render(Context(context))
|
||||
send_mail(mail.title, message,
|
||||
from_email, [to],
|
||||
fail_silently=True)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue