mirror of
https://github.com/Southampton-RSG/breccia-mapper.git
synced 2026-03-03 11:27:09 +00:00
feat: Send welcome email from template
This commit is contained in:
@@ -5,6 +5,8 @@ from django.urls import reverse
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from django_countries.fields import CountryField
|
||||
from django_settings_export import settings_export
|
||||
from post_office import mail
|
||||
|
||||
from backports.db.models.enums import TextChoices
|
||||
|
||||
@@ -28,6 +30,22 @@ class User(AbstractUser):
|
||||
"""
|
||||
return hasattr(self, 'person')
|
||||
|
||||
def send_welcome_email(self):
|
||||
"""Send a welcome email to a new user."""
|
||||
# Get exported data from settings.py first
|
||||
context = settings_export(None)
|
||||
context.update({
|
||||
'user': self,
|
||||
})
|
||||
|
||||
mail.send(
|
||||
[self.email],
|
||||
sender=settings.DEFAULT_FROM_EMAIL,
|
||||
template=settings.TEMPLATE_WELCOME_EMAIL_NAME,
|
||||
context=context,
|
||||
priority='now' # Send immediately - don't add to queue
|
||||
)
|
||||
|
||||
|
||||
class Organisation(models.Model):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user