from django.conf import settings from django.template.loader import render_to_string from django_q.tasks import async_task def registration_template(institution, sponsor) -> str: keywords = { "institution": institution, "sponsor": sponsor, "registration_link": "www.google.com", } return render_to_string("guest_registration.txt", keywords) def confirmation_template(guest) -> str: keywords = {"guest": guest, "confirmation_link": "www.google.com"} return render_to_string("sponsor_confirmation.txt", keywords) def send_registration_mail(mail_to, sponsor) -> str: return async_task( "django.core.mail.send_mail", **{ "subject": "Subject", "message": registration_template(settings.INSTANCE_NAME, sponsor), "from_email": None, "recipient_list": [mail_to], } ) def send_confirmation_mail(mail_to, guest) -> str: return async_task( "django.core.mail.send_mail", **{ "subject": "Subject", "message": confirmation_template(guest), "from_email": None, "recipient_list": [mail_to], } )