From d399534a48b4e54ea0d272ad154e49b0fc34d68d Mon Sep 17 00:00:00 2001 From: Robert Date: Mon, 12 Apr 2021 11:40:09 +0200 Subject: [PATCH] Add signal handling for account creation, refs #2 --- userausfall/__init__.py | 1 + userausfall/apps.py | 8 ++++++++ userausfall/signals.py | 10 ++++++++++ 3 files changed, 19 insertions(+) create mode 100644 userausfall/apps.py create mode 100644 userausfall/signals.py diff --git a/userausfall/__init__.py b/userausfall/__init__.py index e69de29..cb93fbb 100644 --- a/userausfall/__init__.py +++ b/userausfall/__init__.py @@ -0,0 +1 @@ +default_app_config = 'userausfall.apps.UserausfallConfig' diff --git a/userausfall/apps.py b/userausfall/apps.py new file mode 100644 index 0000000..5c928df --- /dev/null +++ b/userausfall/apps.py @@ -0,0 +1,8 @@ +from django.apps import AppConfig + + +class UserausfallConfig(AppConfig): + name = 'userausfall' + + def ready(self): + from . import signals diff --git a/userausfall/signals.py b/userausfall/signals.py new file mode 100644 index 0000000..f5a984b --- /dev/null +++ b/userausfall/signals.py @@ -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')