forked from DGNum/gestioCOF
Phase out custommail in petitscours
This commit is contained in:
parent
eb3cba31a7
commit
edf6a03bc4
1 changed files with 28 additions and 15 deletions
|
@ -1,6 +1,5 @@
|
|||
import json
|
||||
|
||||
from custommail.shortcuts import render_custom_mail
|
||||
from django.conf import settings
|
||||
from django.contrib import messages
|
||||
from django.contrib.auth.decorators import login_required
|
||||
|
@ -8,6 +7,7 @@ from django.contrib.auth.models import User
|
|||
from django.core import mail
|
||||
from django.db import transaction
|
||||
from django.shortcuts import get_object_or_404, redirect, render
|
||||
from django.template import loader
|
||||
from django.utils import timezone
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
from django.views.generic import DetailView, ListView
|
||||
|
@ -70,15 +70,18 @@ def _finalize_traitement(
|
|||
proposed_for.setdefault(user, []).append(matiere)
|
||||
|
||||
proposed_mails = _generate_eleve_email(demande, proposed_for)
|
||||
mainmail = render_custom_mail(
|
||||
"petits-cours-mail-demandeur",
|
||||
{
|
||||
"proposals": proposals.items(),
|
||||
"unsatisfied": unsatisfied,
|
||||
"extra": '<textarea name="extra" '
|
||||
'style="width:99%; height: 90px;">'
|
||||
"</textarea>",
|
||||
},
|
||||
mainmail = (
|
||||
"Cours particuliers ENS",
|
||||
loader.render_to_string(
|
||||
"petitscours/mails/demandeur.txt",
|
||||
context={
|
||||
"proposals": proposals.items(),
|
||||
"unsatisfied": unsatisfied,
|
||||
"extra": '<textarea name="extra" '
|
||||
'style="width:99%; height: 90px;">'
|
||||
"</textarea>",
|
||||
},
|
||||
),
|
||||
)
|
||||
if errors is not None:
|
||||
for error in errors:
|
||||
|
@ -100,11 +103,16 @@ def _finalize_traitement(
|
|||
|
||||
|
||||
def _generate_eleve_email(demande, proposed_for):
|
||||
subject = "Petits cours ENS par le COF"
|
||||
return [
|
||||
(
|
||||
user,
|
||||
render_custom_mail(
|
||||
"petit-cours-mail-eleve", {"demande": demande, "matieres": matieres}
|
||||
(
|
||||
subject,
|
||||
loader.render_to_string(
|
||||
"petitscours/mails/eleve.txt",
|
||||
context={"demande": demande, "matieres": matieres},
|
||||
),
|
||||
),
|
||||
)
|
||||
for user, matieres in proposed_for.items()
|
||||
|
@ -197,9 +205,14 @@ def _traitement_post(request, demande):
|
|||
else:
|
||||
proposed_for[user].append(matiere)
|
||||
proposed_mails = _generate_eleve_email(demande, proposed_for)
|
||||
mainmail_object, mainmail_body = render_custom_mail(
|
||||
"petits-cours-mail-demandeur",
|
||||
{"proposals": proposals.items(), "unsatisfied": unsatisfied, "extra": extra},
|
||||
mainmail_object = "Cours particuliers ENS"
|
||||
mainmail_body = loader.render_to_string(
|
||||
"petitscours/mails/demandeur.txt",
|
||||
context={
|
||||
"proposals": proposals.items(),
|
||||
"unsatisfied": unsatisfied,
|
||||
"extra": extra,
|
||||
},
|
||||
)
|
||||
frommail = settings.MAIL_DATA["petits_cours"]["FROM"]
|
||||
bccaddress = settings.MAIL_DATA["petits_cours"]["BCC"]
|
||||
|
|
Loading…
Reference in a new issue