Skip to content

Commit

Permalink
♻️(mails) link email from current site
Browse files Browse the repository at this point in the history
The link in the email was pointing on the
staging website. We now use a variable to
target the current site setup in the database.
  • Loading branch information
AntoLC committed Jun 4, 2024
1 parent e5e19e6 commit 6d49549
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/backend/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from django.conf import settings
from django.contrib.auth import models as auth_models
from django.contrib.auth.base_user import AbstractBaseUser
from django.contrib.sites.models import Site
from django.core import exceptions, mail, validators
from django.db import models, transaction
from django.template.loader import render_to_string
Expand Down Expand Up @@ -660,6 +661,7 @@ def email_invitation(self):
with override(self.issuer.language):
template_vars = {
"title": _("Invitation to join Desk!"),
"site": Site.objects.get_current()
}
msg_html = render_to_string("mail/html/invitation.html", template_vars)
msg_plain = render_to_string("mail/text/invitation.txt", template_vars)
Expand Down
1 change: 1 addition & 0 deletions src/backend/core/tests/test_models_invitations.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ def test_models_team_invitations_email():

email_content = " ".join(email.body.split())
assert "Invitation to join Desk!" in email_content
assert "[//example.com]" in email_content


@mock.patch(
Expand Down
2 changes: 1 addition & 1 deletion src/mail/mjml/invitation.mjml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<li>{% trans "Facilitate exchanges and communication with our messaging and group discussion tools."%}</li>
</ul>
</mj-text>
<mj-button href="https://desk-staging.beta.numerique.gouv.fr/" background-color="#000091" color="white" padding-bottom="30px">
<mj-button href="//{{site.domain}}" background-color="#000091" color="white" padding-bottom="30px">
{% trans "Visit Equipes"%}
</mj-button>
<mj-text>{% trans "We are confident that Equipes will help you increase efficiency and productivity while strengthening the bond among members." %}</mj-text>
Expand Down

0 comments on commit 6d49549

Please sign in to comment.