SkyLearn-Test/accounts/signals.py
Adil Mohak 4dad1fc0ae Support sqlite3, using thread to send emails, etc.
Lighten the project by supporting sqlite3 and also handling email using only python threads
2024-09-12 10:56:04 +03:00

28 lines
912 B
Python

from .utils import (
generate_student_credentials,
generate_lecturer_credentials,
send_new_account_email,
)
def post_save_account_receiver(sender, instance=None, created=False, *args, **kwargs):
"""
Send email notification
"""
if created:
if instance.is_student:
username, password = generate_student_credentials()
instance.username = username
instance.set_password(password)
instance.save()
# Send email with the generated credentials
send_new_account_email(instance, password)
if instance.is_lecturer:
username, password = generate_lecturer_credentials()
instance.username = username
instance.set_password(password)
instance.save()
# Send email with the generated credentials
send_new_account_email(instance, password)