Catch errors while sending K-Fêt reminder emails #808
1 changed files with 27 additions and 17 deletions
|
@ -1,4 +1,6 @@
|
||||||
|
import logging
|
||||||
import re
|
import re
|
||||||
|
import smtplib
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
|
@ -20,6 +22,8 @@ from .auth.models import GenericTeamToken # noqa
|
||||||
from .config import kfet_config
|
from .config import kfet_config
|
||||||
from .utils import to_ukf
|
from .utils import to_ukf
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class AccountManager(models.Manager):
|
class AccountManager(models.Manager):
|
||||||
"""Manager for Account Model."""
|
"""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.
|
Envoie un mail de rappel signalant que la personne est en négatif.
|
||||||
"""
|
"""
|
||||||
# On envoie le mail
|
# On envoie le mail
|
||||||
|
try:
|
||||||
send_mail(
|
send_mail(
|
||||||
"Compte K-Psul négatif",
|
"Compte K-Psul négatif",
|
||||||
loader.render_to_string(
|
loader.render_to_string(
|
||||||
|
@ -314,7 +319,12 @@ class AccountNegative(models.Model):
|
||||||
# On enregistre le fait que l'envoi a bien eu lieu
|
# On enregistre le fait que l'envoi a bien eu lieu
|
||||||
self.last_rappel = timezone.now()
|
self.last_rappel = timezone.now()
|
||||||
self.save()
|
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):
|
class CheckoutQuerySet(models.QuerySet):
|
||||||
|
|
Loading…
Reference in a new issue