From 0e5260711fe71e24b734d14cfa19dcefe94430a5 Mon Sep 17 00:00:00 2001 From: Raymond Penners Date: Thu, 12 Dec 2024 19:43:19 +0100 Subject: [PATCH] feat(account): add `request` to email context --- allauth/account/adapter.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/allauth/account/adapter.py b/allauth/account/adapter.py index bcff9b48fb..7e5f1be478 100644 --- a/allauth/account/adapter.py +++ b/allauth/account/adapter.py @@ -191,10 +191,12 @@ def render_mail(self, template_prefix, email, context, headers=None): msg.content_subtype = "html" # Main content is now text/html return msg - def send_mail(self, template_prefix, email, context): + def send_mail(self, template_prefix: str, email: str, context: dict) -> None: + request = globals()["context"].request ctx = { + "request": request, "email": email, - "current_site": get_current_site(globals()["context"].request), + "current_site": get_current_site(request), } ctx.update(context) msg = self.render_mail(template_prefix, email, ctx) @@ -601,7 +603,7 @@ def get_email_confirmation_url(self, request, emailconfirmation): def should_send_confirmation_mail(self, request, email_address, signup) -> bool: return True - def send_account_already_exists_mail(self, email): + def send_account_already_exists_mail(self, email: str) -> None: from allauth.account.internal import flows signup_url = flows.signup.get_signup_url(context.request) @@ -609,7 +611,6 @@ def send_account_already_exists_mail(self, email): context.request ) ctx = { - "request": context.request, "signup_url": signup_url, "password_reset_url": password_reset_url, }