2017-12-12 04:19:45 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
#
|
|
|
|
|
|
|
|
from django.dispatch import Signal, receiver
|
2018-01-12 07:43:26 +00:00
|
|
|
from django.db.models.signals import post_save
|
2017-12-12 04:19:45 +00:00
|
|
|
|
|
|
|
from common.utils import get_logger
|
2018-01-12 07:43:26 +00:00
|
|
|
from .models import User
|
2017-12-12 04:19:45 +00:00
|
|
|
|
|
|
|
logger = get_logger(__file__)
|
|
|
|
|
|
|
|
|
2018-01-12 07:43:26 +00:00
|
|
|
@receiver(post_save, sender=User)
|
|
|
|
def on_user_created(sender, instance=None, created=False, **kwargs):
|
|
|
|
if created:
|
|
|
|
logger.debug("Receive user `{}` create signal".format(instance.name))
|
|
|
|
from .utils import send_user_created_mail
|
|
|
|
logger.info(" - Sending welcome mail ...".format(instance.name))
|
2018-01-26 08:06:23 +00:00
|
|
|
if instance.email:
|
|
|
|
send_user_created_mail(instance)
|
2017-12-12 04:19:45 +00:00
|
|
|
|