Skip to content

Commit 5985704

Browse files
committed
add an e-mail to notify the user that they have an NGO Hub account
1 parent d943f59 commit 5985704

File tree

6 files changed

+384
-222
lines changed

6 files changed

+384
-222
lines changed

backend/donations/views/account_management.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,11 @@ def post(self, request, *args, **kwargs):
4646
except self.user_model.DoesNotExist:
4747
user = None
4848

49-
if user and not user.is_ngohub_user:
50-
self._send_password_reset_email(request, user)
51-
elif user.is_ngohub_user:
52-
# TODO: send an e-mail to the user
53-
# notify them that they should log in through NGO Hub
54-
pass
49+
if user:
50+
if not (user.is_ngohub_user or user.ngo and user.ngo.ngohub_org_id):
51+
self._send_password_reset_email(request, user)
52+
else:
53+
self._send_ngohub_notification(request, user)
5554

5655
messages.success(
5756
request,
@@ -87,6 +86,22 @@ def _send_password_reset_email(self, request: HttpRequest, user: UserModel):
8786
context=template_context,
8887
)
8988

89+
def _send_ngohub_notification(self, request: HttpRequest, user: UserModel):
90+
template_context = {
91+
"first_name": user.first_name,
92+
"contact_email": settings.CONTACT_EMAIL_ADDRESS,
93+
"ngohub_site": settings.NGOHUB_APP_BASE,
94+
}
95+
template_context.update(extend_email_context(request))
96+
97+
send_email(
98+
subject=_("Your redirectioneaza.ro account"),
99+
to_emails=[user.email],
100+
text_template="emails/account/ngohub-notification/main.txt",
101+
html_template="emails/account/ngohub-notification/main.html",
102+
context=template_context,
103+
)
104+
90105

91106
class LoginView(BaseVisibleTemplateView):
92107
template_name = "account/login.html"

0 commit comments

Comments
 (0)