From 14a14e973a5e81a16a740bca8c460f9539c148a2 Mon Sep 17 00:00:00 2001 From: wlorenzetti Date: Fri, 29 Sep 2023 09:54:44 +0200 Subject: [PATCH] Fix send email on activation by administrator for only registered users. --- g3w-admin/usersmanage/receivers.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/g3w-admin/usersmanage/receivers.py b/g3w-admin/usersmanage/receivers.py index c80cdda1c..644ebdb52 100644 --- a/g3w-admin/usersmanage/receivers.py +++ b/g3w-admin/usersmanage/receivers.py @@ -67,6 +67,7 @@ def send_email_to_user(sender, **kwargs): if (not hasattr(user, 'userdata') or not sender.request.user.is_superuser or + user.userdata.registered == False or user.userdata.activated_by_admin): return @@ -78,9 +79,14 @@ def send_email_to_user(sender, **kwargs): # Send email to user # ---------------------------------------------------------- scheme = "https" if hasattr(sender.request, 'is_secure') and sender.request.is_secure() else "http" + try: + site = get_current_site(sender.request) + except: + site = 'localhost' + context = { "scheme": scheme, - "site": get_current_site(sender.request), + "site": site, "user": user } subject = render_to_string(