✨(teams) update and enhance team invitation email
- replace logo - modify wording - enhance template
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user