Coverage for apps/users/services.py: 31%
16 statements
« prev ^ index » next coverage.py v6.4.4, created at 2024-04-19 09:45 -0600
« prev ^ index » next coverage.py v6.4.4, created at 2024-04-19 09:45 -0600
1from django.conf import settings
2from sentry_sdk import capture_exception
4from app.sendgrid import SendgridClient
7def send_password_reset_email(user, url):
8 try:
9 sendgrid = SendgridClient(
10 to=user.email,
11 )
12 sendgrid.send_dynamic_email(
13 template_id=settings.SENDGRID_RESET_PASSWORD_TEMPLATE,
14 dynamic_template_data={
15 "url": url,
16 },
17 )
18 except Exception as e:
19 capture_exception(e)
22def send_welcome_user_with_invitation_email(user, password_url, affiliation):
23 invitation_url = f"{settings.FRONTEND_DOMAIN}/invitation/{affiliation.random_slug}"
24 try:
25 sendgrid = SendgridClient(
26 to=user.email,
27 )
28 sendgrid.send_dynamic_email(
29 template_id=settings.SENDGRID_WELCOME_USER_WITH_INVITATION_TEMPLATE,
30 dynamic_template_data={
31 "organization": affiliation.organization.name,
32 "password_url": password_url,
33 "invitation_url": invitation_url,
34 },
35 )
36 except Exception as e:
37 capture_exception(e)