From 5730b9ea5e5525015c99c3203c4b0e8ead3e2e2a Mon Sep 17 00:00:00 2001 From: Sabrina Demagny Date: Mon, 10 Mar 2025 18:44:13 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8(teams)=20update=20and=20enhance=20tea?= =?UTF-8?q?m=20invitation=20email?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - replace logo - modify wording - enhance template --- CHANGELOG.md | 1 + src/backend/core/models.py | 15 ++++ .../core/tests/test_models_invitations.py | 17 +++-- src/backend/debug/views.py | 15 +++- src/mail/mjml/team_invitation.mjml | 71 +++++++++---------- 5 files changed, 75 insertions(+), 44 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d8b4855..4eec689 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to ### Added +- ✨(teams) update and enhance team invitation email - ✨(api) define dimail timeout as a setting - ✨(frontend) feature modal add new access role to domain - ✨(api) allow invitations for domain management #708 diff --git a/src/backend/core/models.py b/src/backend/core/models.py index 42acb17..caa1fd3 100644 --- a/src/backend/core/models.py +++ b/src/backend/core/models.py @@ -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 diff --git a/src/backend/core/tests/test_models_invitations.py b/src/backend/core/tests/test_models_invitations.py index d0518a5..633228e 100644 --- a/src/backend/core/tests/test_models_invitations.py +++ b/src/backend/core/tests/test_models_invitations.py @@ -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 diff --git a/src/backend/debug/views.py b/src/backend/debug/views.py index 26eff8d..ab3285b 100644 --- a/src/backend/debug/views.py +++ b/src/backend/debug/views.py @@ -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" diff --git a/src/mail/mjml/team_invitation.mjml b/src/mail/mjml/team_invitation.mjml index 02cd620..5f49595 100644 --- a/src/mail/mjml/team_invitation.mjml +++ b/src/mail/mjml/team_invitation.mjml @@ -2,56 +2,55 @@ - - + + - - + + - + - -

{% trans "Invitation to join a team" %}

-
- - + -

{% trans "Welcome to" %} La Régie

+ {% trans "Welcome to" %} La Régie
- - - - - {% trans "We are delighted to welcome you to our community on La Régie, your new companion to simplify the management of your groups efficiently, intuitively, and securely." %} - {% trans "Our application is designed to help you organize, collaborate, and manage permissions." %} - - {% trans "With La Régie, you will be able to:" %} -
    -
  • {% trans "Create customized groups according to your specific needs."%}
  • -
  • {% trans "Invite members of your team or community in just a few clicks."%}
  • -
  • {% trans "Plan events, meetings, or activities effortlessly with our integrated calendar."%}
  • -
  • {% trans "Share documents, photos, and important information securely."%}
  • -
  • {% trans "Facilitate exchanges and communication with our messaging and group discussion tools."%}
  • -
+ {% trans "Hello," %} + {% blocktranslate with team=team role=role trimmed %} + You have been invited to be a {{ role }} of the group "{{ team }}" within La Suite. + {% endblocktranslate %} - - {% trans "Visit La Régie"%} + {% trans "To do so, please log in La Régie via ProConnect, by following this link:" %} + + arrow + {% trans "Go to La Régie"%} - {% trans "We are confident that La Régie will help you increase efficiency and productivity while strengthening the bond among members." %} - {% trans "Feel free to explore all the features of the application and share your feedback and suggestions with us. Your feedback is valuable to us and will enable us to continually improve our service." %} - {% trans "Once again, welcome aboard! We are eager to accompany you on this group management adventure." %} - + + + {% trans "What is La Régie?" %} + + + {% trans "La Suite is an open-source work environment, designed for the public sector and open to commons."%} + + + {% trans "With La Suite, you will be able to create, organise and collaborate online!" %} + + + {% trans "For more information:" %} {% trans "Visit the website for La Suite numérique" %} + + + {% trans "Welcome aboard!" %} + -

{% trans "Sincerely," %}

-

{% trans "The La Suite Numérique Team" %}

+

{% trans "Regards," %}

+

{% trans "La Suite Team" %}

+ +
- -