Add signal handling for account creation, refs #2

This commit is contained in:
aldrin 2021-04-12 11:40:09 +02:00
parent f2c2b5493b
commit d399534a48
3 changed files with 19 additions and 0 deletions

View file

@ -0,0 +1 @@
default_app_config = 'userausfall.apps.UserausfallConfig'

8
userausfall/apps.py Normal file
View file

@ -0,0 +1,8 @@
from django.apps import AppConfig
class UserausfallConfig(AppConfig):
name = 'userausfall'
def ready(self):
from . import signals

10
userausfall/signals.py Normal file
View file

@ -0,0 +1,10 @@
from django.db.models.signals import post_save
from django.dispatch import receiver
from userausfall.models import AccountRequest
@receiver(post_save, sender=AccountRequest)
def account_request_saved(sender, instance: AccountRequest, **kwargs):
if instance.is_verified and instance.is_trustable and instance.username:
print('Create account and send password mail')