forked from DGNum/gestioCOF
Catch errors while sending K-Fêt reminder emails
This commit is contained in:
parent
1c880b265e
commit
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,6 +302,7 @@ class AccountNegative(models.Model):
|
|||
Envoie un mail de rappel signalant que la personne est en négatif.
|
||||
"""
|
||||
# On envoie le mail
|
||||
try:
|
||||
send_mail(
|
||||
"Compte K-Psul négatif",
|
||||
loader.render_to_string(
|
||||
|
@ -314,7 +319,12 @@ class AccountNegative(models.Model):
|
|||
# On enregistre le fait que l'envoi a bien eu lieu
|
||||
self.last_rappel = timezone.now()
|
||||
self.save()
|
||||
return
|
||||
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