8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-12-23 15:33:45 +00:00

cement de l'adresse si besoin lors d'envois du mail

This commit is contained in:
grisel-davy 2018-08-17 13:27:40 +02:00
parent 9df9149894
commit 69c8c9f204
2 changed files with 34 additions and 5 deletions

View file

@ -85,11 +85,16 @@ def send_mail_invoice(invoice):
'asso_name': AssoOption.get_cached_value('name') 'asso_name': AssoOption.get_cached_value('name')
} }
if GeneralOption.get_cached_value('all_mail_redirect'):
address = GeneralOption.get_cached_value('redirect_address')
else:
address = invoice.user.email
mail = EmailMessage( mail = EmailMessage(
'Votre facture / Your invoice', 'Votre facture / Your invoice',
template.render(ctx), template.render(ctx),
GeneralOption.get_cached_value('email_from'), GeneralOption.get_cached_value('email_from'),
[invoice.user.email], [address],
attachments=[('invoice.pdf', pdf, 'application/pdf')] attachments=[('invoice.pdf', pdf, 'application/pdf')]
) )
mail.send() mail.send()

View file

@ -616,13 +616,19 @@ class User(RevMixin, FieldPermissionModelMixin, AbstractBaseUser,
'welcome_mail_en': mailmessageoptions.welcome_mail_en, 'welcome_mail_en': mailmessageoptions.welcome_mail_en,
'pseudo': self.pseudo, 'pseudo': self.pseudo,
}) })
if GeneralOption.get_cached_value('all_mail_redirect'):
address = GeneralOption.get_cached_value('redirect_address')
else:
address = self.email
send_mail( send_mail(
'Bienvenue au %(name)s / Welcome to %(name)s' % { 'Bienvenue au %(name)s / Welcome to %(name)s' % {
'name': AssoOption.get_cached_value('name') 'name': AssoOption.get_cached_value('name')
}, },
'', '',
GeneralOption.get_cached_value('email_from'), GeneralOption.get_cached_value('email_from'),
[self.email], [address],
html_message=template.render(context) html_message=template.render(context)
) )
return return
@ -647,12 +653,18 @@ class User(RevMixin, FieldPermissionModelMixin, AbstractBaseUser,
GeneralOption.get_cached_value('req_expire_hrs') GeneralOption.get_cached_value('req_expire_hrs')
) + ' heures', ) + ' heures',
} }
if GeneralOption.get_cached_value('all_mail_redirect'):
address = GeneralOption.get_cached_value('redirect_address')
else:
address = req.user.email
send_mail( send_mail(
'Changement de mot de passe du %(name)s / Password renewal for ' 'Changement de mot de passe du %(name)s / Password renewal for '
'%(name)s' % {'name': AssoOption.get_cached_value('name')}, '%(name)s' % {'name': AssoOption.get_cached_value('name')},
template.render(context), template.render(context),
GeneralOption.get_cached_value('email_from'), GeneralOption.get_cached_value('email_from'),
[req.user.email], [address],
fail_silently=False fail_silently=False
) )
return return
@ -704,11 +716,17 @@ class User(RevMixin, FieldPermissionModelMixin, AbstractBaseUser,
'asso_email': AssoOption.get_cached_value('contact'), 'asso_email': AssoOption.get_cached_value('contact'),
'pseudo': self.pseudo, 'pseudo': self.pseudo,
}) })
if GeneralOption.get_cached_value('all_mail_redirect'):
address = GeneralOption.get_cached_value('redirect_address')
else:
address = self.email
send_mail( send_mail(
"Ajout automatique d'une machine / New machine autoregistered", "Ajout automatique d'une machine / New machine autoregistered",
'', '',
GeneralOption.get_cached_value('email_from'), GeneralOption.get_cached_value('email_from'),
[self.email], [address],
html_message=template.render(context) html_message=template.render(context)
) )
return return
@ -1391,11 +1409,17 @@ class Ban(RevMixin, AclMixin, models.Model):
'date_end': self.date_end, 'date_end': self.date_end,
'asso_name': AssoOption.get_cached_value('name'), 'asso_name': AssoOption.get_cached_value('name'),
}) })
if GeneralOption.get_cached_value('all_mail_redirect'):
address = GeneralOption.get_cached_value('redirect_address')
else:
address = self.user.email
send_mail( send_mail(
'Deconnexion disciplinaire', 'Deconnexion disciplinaire',
template.render(context), template.render(context),
GeneralOption.get_cached_value('email_from'), GeneralOption.get_cached_value('email_from'),
[self.user.email], [address],
fail_silently=False fail_silently=False
) )
return return