forked from DGNum/gestioCOF
Compare commits
1 commit
master
...
kerl/negat
Author | SHA1 | Date | |
---|---|---|---|
|
e18873115a |
1 changed files with 27 additions and 17 deletions
|
@ -1,4 +1,6 @@
|
|||
import logging
|
||||
import re
|
||||
import smtplib
|
||||
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.models import User
|
||||
|
@ -20,6 +22,8 @@ from .auth.models import GenericTeamToken # noqa
|
|||
from .config import kfet_config
|
||||
from .utils import to_ukf
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class AccountManager(models.Manager):
|
||||
"""Manager for Account Model."""
|
||||
|
@ -298,23 +302,29 @@ class AccountNegative(models.Model):
|
|||
Envoie un mail de rappel signalant que la personne est en négatif.
|
||||
"""
|
||||
# On envoie le mail
|
||||
send_mail(
|
||||
"Compte K-Psul négatif",
|
||||
loader.render_to_string(
|
||||
"kfet/mails/rappel.txt",
|
||||
context={
|
||||
"account": self.account,
|
||||
"neg_amount": -self.account.balance,
|
||||
"start_date": self.start,
|
||||
},
|
||||
),
|
||||
settings.MAIL_DATA["rappel_negatif"]["FROM"],
|
||||
[self.account.email],
|
||||
)
|
||||
# On enregistre le fait que l'envoi a bien eu lieu
|
||||
self.last_rappel = timezone.now()
|
||||
self.save()
|
||||
return
|
||||
try:
|
||||
send_mail(
|
||||
"Compte K-Psul négatif",
|
||||
loader.render_to_string(
|
||||
"kfet/mails/rappel.txt",
|
||||
context={
|
||||
"account": self.account,
|
||||
"neg_amount": -self.account.balance,
|
||||
"start_date": self.start,
|
||||
},
|
||||
),
|
||||
settings.MAIL_DATA["rappel_negatif"]["FROM"],
|
||||
[self.account.email],
|
||||
)
|
||||
# On enregistre le fait que l'envoi a bien eu lieu
|
||||
self.last_rappel = timezone.now()
|
||||
self.save()
|
||||
except smtplib.SMTPException:
|
||||
logger.warning(
|
||||
"L'envoi du mail de rappel pour le négatif de {} a échoué".format(
|
||||
self.account
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
class CheckoutQuerySet(models.QuerySet):
|
||||
|
|
Loading…
Reference in a new issue