diff --git a/core/models.py b/core/models.py index 17998b9..0207fc3 100644 --- a/core/models.py +++ b/core/models.py @@ -1,5 +1,7 @@ from django.db import models from django.contrib.auth.models import AbstractUser +from django.dispatch import receiver +from django.db.models.signals import post_save from django.utils.translation import gettext_lazy as _ from django.conf import settings from django.core.mail import send_mail @@ -56,4 +58,15 @@ def send_mail(self, to_list: list[str], context): print(f"Error sending email with type {type(e)}: {e}") def __str__(self): - return f"{self.name} - [{self.event}]" \ No newline at end of file + return f"{self.name} - [{self.event}]" + +@receiver(post_save, sender=PawUser, dispatch_uid="new_user_notification") +def new_user_notification(sender, instance, created, **kwargs): + if not created or not instance.email: + return None + + mail_template = MailTemplate.get_template('new_user', instance.language) + if not mail_template: + return None + mail_template.send_mail([instance.email], { + 'username': instance.username, 'email': instance.email }) \ No newline at end of file diff --git a/paw/templates/ticketing/tickets.html b/paw/templates/ticketing/tickets.html index 37a97a2..aec4493 100644 --- a/paw/templates/ticketing/tickets.html +++ b/paw/templates/ticketing/tickets.html @@ -3,7 +3,11 @@ {% load i18n %}