Merge branch 'Kerl/settings_syntax' into 'master'

Meilleure gestion des données mails

Les valeurs de champs FROM, REPLY-TO et BCC des mails envoyés par
GestioCOF sont enregistrées dans un dictionnaire `settings.MAIL_DATA`
plutôt que d'être toutes enregistrées comme variables indépendantes.

See merge request !88
This commit is contained in:
Martin Pepin 2016-10-04 12:10:40 +02:00
commit fbc4158de7
3 changed files with 26 additions and 18 deletions

View file

@ -123,8 +123,9 @@ class Spectacle(models.Model):
'show': self})
mail_tot = mail.EmailMessage(
mail_object, mail_body,
settings.RAPPEL_FROM, [member[2]],
[], headers={'Reply-To': settings.RAPPEL_REPLY_TO})
settings.MAIL_DATA['rappels']['FROM'], [member[2]],
[], headers={
'Reply-To': settings.MAIL_DATA['rappels']['REPLYTO']})
mails_to_send.append(mail_tot)
# On envoie les mails
connection = mail.get_connection()
@ -283,8 +284,10 @@ class SpectacleRevente(models.Model):
'domain': Site.objects.get_current().domain})
mail_tot = mail.EmailMessage(
mail_object, mail_body,
settings.REVENTE_FROM, [participant.user.email],
[], headers={'Reply-To': settings.REVENTE_REPLY_TO})
settings.MAIL_DATA['revente']['FROM'],
[participant.user.email],
[], headers={
'Reply-To': settings.MAIL_DATA['revente']['REPLYTO']})
mails_to_send.append(mail_tot)
connection = mail.get_connection()
@ -305,8 +308,10 @@ class SpectacleRevente(models.Model):
'mail': self.attribution.participant.user.email})
mail_tot = mail.EmailMessage(
mail_object, mail_body,
settings.REVENTE_FROM, [participant.user.email],
[], headers={'Reply-To': settings.REVENTE_REPLY_TO})
settings.MAIL_DATA['revente']['FROM'],
[participant.user.email],
[], headers={
'Reply-To': settings.MAIL_DATA['revente']['REPLYTO']})
mails_to_send.append(mail_tot)
connection = mail.get_connection()

View file

@ -145,15 +145,18 @@ ADMIN_MEDIA_PREFIX = '/static/grappelli/'
GRAPPELLI_ADMIN_HEADLINE = "GestioCOF"
GRAPPELLI_ADMIN_TITLE = "<a href=\"/\">GestioCOF</a>"
PETITS_COURS_FROM = "Le COF <cof@ens.fr>"
PETITS_COURS_BCC = "archivescof@gmail.com"
PETITS_COURS_REPLYTO = "cof@ens.fr"
RAPPEL_FROM = 'Le BdA <bda@ens.fr>'
RAPPEL_REPLY_TO = RAPPEL_FROM
REVENTE_FROM = 'BdA-Revente <bda-revente@ens.fr>'
REVENTE_REPLY_TO = REVENTE_FROM
MAIL_DATA = {
'petits_cours': {
'FROM': "Le COF <cof@ens.fr>",
'BCC': "archivescof@gmail.com",
'REPLYTO': "cof@ens.fr"},
'rappels': {
'FROM': 'Le BdA <bda@ens.fr>',
'REPLYTO': 'Le BdA <bda@ens.fr>'},
'revente': {
'FROM': 'BdA-Revente <bda-revente@ens.fr>',
'REPLYTO': 'BdA-Revente <bda-revente@ens.fr>'},
}
LOGIN_URL = "/gestion/login"
LOGIN_REDIRECT_URL = "/gestion/"

View file

@ -282,9 +282,9 @@ def _traitement_post(request, demande):
{"proposals": proposals_list,
"unsatisfied": unsatisfied,
"extra": extra})
frommail = settings.PETITS_COURS_FROM
bccaddress = settings.PETITS_COURS_BCC
replyto = settings.PETITS_COURS_REPLYTO
frommail = settings.MAIL_DATA['petits_cours']['FROM']
bccaddress = settings.MAIL_DATA['petits_cours']['BCC']
replyto = settings.MAIL_DATA['petits_cours']['REPLYTO']
mails_to_send = []
for (user, msg) in proposed_mails:
msg = EmailMessage("Petits cours ENS par le COF", msg,