Get first signup email through
This commit is contained in:
+11
-10
@@ -14,7 +14,6 @@ from phonenumber_field.modelfields import PhoneNumberField
|
||||
from django.contrib.postgres.fields import JSONField
|
||||
from uuid import uuid4
|
||||
import logging
|
||||
from smtplib import SMTPAuthenticationError
|
||||
|
||||
VERBOSE_NAME = _('Webapp')
|
||||
EMAIL_REGEX = r"(^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$)"
|
||||
@@ -186,18 +185,20 @@ class Signup(models.Model):
|
||||
|
||||
|
||||
@receiver(post_save, sender=Signup)
|
||||
def email_on_singup(sender, instance, created, **kwargs):
|
||||
def email_on_signup(sender, instance, created, **kwargs):
|
||||
"""Send email validation."""
|
||||
if not settings.ENABLE_AUTOMATIC_EMAILS:
|
||||
return
|
||||
|
||||
try:
|
||||
if created and instance.email:
|
||||
# TODO: Possible bug due to many-to-many relationship with events and forms.
|
||||
subject = _(f"Olet ilmoittautunut tapahtumaan {instance.signupForm.event.first().title}")
|
||||
send_signup_email(instance.email, subject, instance.id, instance.uuid)
|
||||
except SMTPAuthenticationError:
|
||||
logging.error('Failed to send email to signup')
|
||||
if created and instance.email:
|
||||
# TODO: Possible bug due to many-to-many relationship with events and forms.
|
||||
# TODO: Subject field crashes with lazy loaded translations.
|
||||
try:
|
||||
# subject = _(f"Olet ilmoittautunut tapahtumaan {instance.signupForm.event.first().title}")
|
||||
subject = f"Olet ilmoittautunut tapahtumaan {instance.signupForm.event.first().title}"
|
||||
except AttributeError:
|
||||
# subject = _(f"Olet ilmoittautunut ilmoon {instance.signupForm.title}")
|
||||
subject = f"Olet ilmoittautunut ilmoon {instance.signupForm.title}"
|
||||
send_signup_email(instance.email, subject, instance.id, instance.uuid)
|
||||
|
||||
|
||||
class BaseRole(models.Model):
|
||||
|
||||
Reference in New Issue
Block a user