Free and open source ticket system written in python

fix: send mail notification on user creation

Signed-off-by: A. Ottr <alex@otter.foo>

+14 -1
+14 -1
core/models.py
··· 1 1 from django.db import models 2 2 from django.contrib.auth.models import AbstractUser 3 3 from django.utils.translation import gettext_lazy as _ 4 + from django.dispatch import receiver 5 + from django.db.models.signals import post_save 4 6 from django.conf import settings 5 7 from django.core.mail import send_mail 6 8 ··· 56 58 print(f"Error sending email with type {type(e)}: {e}") 57 59 58 60 def __str__(self): 59 - return f"{self.name} - [{self.event}]" 61 + return f"{self.name} - [{self.event}]" 62 + 63 + @receiver(post_save, sender=PawUser, dispatch_uid="new_user_notification") 64 + def new_user_notification(sender, instance, created, **kwargs): 65 + if not created or not instance.email: 66 + return None 67 + 68 + mail_template = MailTemplate.get_template('new_user', instance.language) 69 + if not mail_template: 70 + return None 71 + mail_template.send_mail([instance.email], { 72 + 'username': instance.username, 'email': instance.email })