...
 
Commits (3)
......@@ -84,12 +84,17 @@ def send_mail_invoice(invoice):
'contact_mail': AssoOption.get_cached_value('contact'),
'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(
'Votre facture / Your invoice',
template.render(ctx),
GeneralOption.get_cached_value('email_from'),
[invoice.user.email],
[address],
attachments=[('invoice.pdf', pdf, 'application/pdf')]
)
mail.send()
......@@ -868,7 +868,7 @@ def credit_solde(request, user, **_kwargs):
p = get_object_or_404(Paiement, is_balance=True)
return form({
'factureform': refill_form,
'balance': request.user.solde,
'balance': user.solde,
'title': _("Refill your balance"),
'action_name': _("Pay"),
'max_balance': p.payment_method.maximum_balance,
......
......@@ -126,6 +126,8 @@ class EditGeneralOptionForm(ModelForm):
self.fields['email_from'].label = "Adresse mail d\
'expedition automatique"
self.fields['GTU_sum_up'].label = "Résumé des CGU"
self.fields['all_mail_redirect'].label = "Redirection de tout les mails"
self.fields['redirect_address'].label = 'Adresse de redirection'
class EditAssoOptionForm(ModelForm):
......
# -*- coding: utf-8 -*-
# Generated by Django 1.10.7 on 2018-08-17 11:08
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('preferences', '0049_optionaluser_self_change_shell'),
]
operations = [
migrations.AddField(
model_name='generaloption',
name='all_mail_redirect',
field=models.BooleanField(default=True, help_text='Redirect all sent mail to the choosen address'),
),
migrations.AddField(
model_name='generaloption',
name='redirect_address',
field=models.EmailField(default='no-reply@example.com', help_text='Where to redirect all mails', max_length=254),
),
]
......@@ -237,6 +237,8 @@ class GeneralOption(AclMixin, PreferencesModel):
req_expire_hrs = models.IntegerField(default=48)
site_name = models.CharField(max_length=32, default="Re2o")
email_from = models.EmailField(default="www-data@example.com")
all_mail_redirect = models.BooleanField(default=True, help_text="Redirect all sent mail to the choosen address")
redirect_address = models.EmailField(default="no-reply@example.com", help_text="Where to redirect all mails")
GTU_sum_up = models.TextField(
default="",
blank=True,
......
......@@ -160,6 +160,14 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<th>CGU</th>
<td>{{generaloptions.GTU}}</th>
</tr>
</tr>
<th>Redirection des mails envoyés</th>
<td>{{ generaloptions.all_mail_redirect|tick }}</td>
{% if generaloptions.all_mail_redirect %}
<th> Adresse mail de redirection <th>
<td>{{ generaloptions.redirect_address }}</td>
{% endif %}
</tr>
</table>
......
......@@ -616,13 +616,19 @@ class User(RevMixin, FieldPermissionModelMixin, AbstractBaseUser,
'welcome_mail_en': mailmessageoptions.welcome_mail_en,
'pseudo': self.pseudo,
})
if GeneralOption.get_cached_value('all_mail_redirect'):
address = GeneralOption.get_cached_value('redirect_address')
else:
address = self.email
send_mail(
'Bienvenue au %(name)s / Welcome to %(name)s' % {
'name': AssoOption.get_cached_value('name')
},
'',
GeneralOption.get_cached_value('email_from'),
[self.email],
[address],
html_message=template.render(context)
)
return
......@@ -647,12 +653,18 @@ class User(RevMixin, FieldPermissionModelMixin, AbstractBaseUser,
GeneralOption.get_cached_value('req_expire_hrs')
) + ' heures',
}
if GeneralOption.get_cached_value('all_mail_redirect'):
address = GeneralOption.get_cached_value('redirect_address')
else:
address = req.user.email
send_mail(
'Changement de mot de passe du %(name)s / Password renewal for '
'%(name)s' % {'name': AssoOption.get_cached_value('name')},
template.render(context),
GeneralOption.get_cached_value('email_from'),
[req.user.email],
[address],
fail_silently=False
)
return
......@@ -704,11 +716,17 @@ class User(RevMixin, FieldPermissionModelMixin, AbstractBaseUser,
'asso_email': AssoOption.get_cached_value('contact'),
'pseudo': self.pseudo,
})
if GeneralOption.get_cached_value('all_mail_redirect'):
address = GeneralOption.get_cached_value('redirect_address')
else:
address = self.email
send_mail(
"Ajout automatique d'une machine / New machine autoregistered",
'',
GeneralOption.get_cached_value('email_from'),
[self.email],
[address],
html_message=template.render(context)
)
return
......@@ -1391,11 +1409,17 @@ class Ban(RevMixin, AclMixin, models.Model):
'date_end': self.date_end,
'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(
'Deconnexion disciplinaire',
template.render(context),
GeneralOption.get_cached_value('email_from'),
[self.user.email],
[address],
fail_silently=False
)
return
......