(teams) update and enhance team invitation email

- replace logo
- modify wording
- enhance template
This commit is contained in:
Sabrina Demagny
2025-03-10 18:44:13 +01:00
parent 7f75efacf8
commit 5730b9ea5e
5 changed files with 75 additions and 44 deletions

View File

@@ -1000,6 +1000,21 @@ class Invitation(BaseInvitation):
def __str__(self):
return f"{self.email} invited to {self.team}"
def _get_mail_subject(self):
"""Get the subject of the team invitation."""
role = self.get_role_display().lower()
return gettext(
f"[La Suite] You have been invited to become a {role} of a group"
)
def _get_mail_context(self):
"""Get the template variables for the invitation."""
return {
**super()._get_mail_context(),
"team": self.team.name,
"role": self.get_role_display().lower(),
}
def get_abilities(self, user):
"""Compute and return abilities for a given user."""
can_delete = False

View File

@@ -241,15 +241,14 @@ def test_models_team_invitations_get_abilities_member():
def test_models_team_invitations_email():
"""Check email invitation during invitation creation."""
member_access = factories.TeamAccessFactory(role="member")
team = member_access.team
team = factories.TeamFactory()
# pylint: disable-next=no-member
assert len(mail.outbox) == 0
factories.TeamAccessFactory(team=team)
# Please add test for french language after translations update
invitation = factories.InvitationFactory(
team=team, email="john@people.com", issuer__language="fr-fr"
role="member", team=team, email="john@people.com", issuer__language="en-us"
)
# pylint: disable-next=no-member
@@ -259,10 +258,16 @@ def test_models_team_invitations_email():
email = mail.outbox[0]
assert email.to == [invitation.email]
assert email.subject == "Invitation à rejoindre La Régie !"
assert (
email.subject
== "[La Suite] You have been invited to become a member of a group"
)
email_content = " ".join(email.body.split())
assert "Nous sommes ravis de vous accueillir" in email_content
assert (
f"""You have been invited to be a member of the group "{team.name}" within La Suite."""
in email_content
)
assert "[//example.com]" in email_content

View File

@@ -14,13 +14,24 @@ class DebugBaseView(TemplateView):
# TEAM INVITATION
class DebugViewTeamInvitationHtml(DebugBaseView):
class DebugViewTeamInvitationBase(DebugBaseView):
"""Debug view for team invitation base email layout"""
def get_context_data(self, **kwargs):
"""Add some fake context data for team invitation email layout"""
context = super().get_context_data(**kwargs)
context["team"] = "example team"
context["role"] = "owner"
return context
class DebugViewTeamInvitationHtml(DebugViewTeamInvitationBase):
"""Debug view for team invitation html email layout"""
template_name = "mail/html/team_invitation.html"
class DebugViewTeamInvitationTxt(DebugBaseView):
class DebugViewTeamInvitationTxt(DebugViewTeamInvitationBase):
"""Debug view for team invitation text email layout"""
template_name = "mail/text/team_invitation.txt"