Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Emails): remplacer l'envoi de finalisation du compte par son TemplateTransactional #1019

Merged
merged 2 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,9 +323,6 @@
GIP_CONTACT_EMAIL = env("GIP_CONTACT_EMAIL", default="[email protected]")

# Transactional email templates
# -- user: new user password reset
MAILJET_NEW_USER_PASSWORD_RESET_ID = env.int("MAILJET_NEW_USER_PASSWORD_RESET_ID", 4216730)

# -- siae: completion
MAILJET_SIAE_COMPLETION_REMINDER_TEMPLATE_ID = env.int("MAILJET_SIAE_COMPLETION_REMINDER_TEMPLATE_ID", 4791779)

Expand Down
13 changes: 6 additions & 7 deletions lemarche/www/auth/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from django.utils.encoding import force_bytes
from django.utils.http import urlsafe_base64_encode

from lemarche.conversations.models import TemplateTransactional
from lemarche.users.models import User
from lemarche.utils.apis import api_mailjet
from lemarche.utils.emails import send_mail_async, whitelist_recipient_list
from lemarche.utils.urls import get_domain_url

Expand Down Expand Up @@ -42,21 +42,20 @@ def send_signup_notification_email(user):


def send_new_user_password_reset_link(user: User):
email_subject = "Finalisez votre inscription sur le marché de l'inclusion"
email_template = TemplateTransactional.objects.get(code="NEW_USER_PASSWORD_RESET")
recipient_list = whitelist_recipient_list([user.email])
if recipient_list:
recipient_email = recipient_list[0] if recipient_list else ""
if len(recipient_list):
recipient_email = recipient_list[0]
recipient_name = user.full_name

variables = {
"USER_FIRST_NAME": user.first_name,
"USER_EMAIL": user.email,
"PASSWORD_RESET_LINK": generate_password_reset_link(user),
}

api_mailjet.send_transactional_email_with_template(
template_id=settings.MAILJET_NEW_USER_PASSWORD_RESET_ID,
email_template.send_transactional_email(
recipient_email=recipient_email,
recipient_name=recipient_name,
variables=variables,
subject=email_subject,
)
Loading