Skip to content

Commit

Permalink
Add personal message to Brevo templates
Browse files Browse the repository at this point in the history
  • Loading branch information
alemangui committed Aug 14, 2024
1 parent 9767f29 commit 9cc4a97
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 13 deletions.
1 change: 1 addition & 0 deletions api/tests/test_company_claims.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def test_company_access_claim_declarant(self, mocked_brevo):
"REQUESTER_NAME": authenticate.user.get_full_name(),
"COMPANY_NAME": company.social_name,
"REQUEST_LINK": f"https://hostname/gestion-des-collaborateurs/{company.id}",
"PERSONAL_MESSAGE": "Je voudrais pouvoir déclarer pour votre entreprise",
},
supervisor.email,
supervisor.get_full_name(),
Expand Down
7 changes: 2 additions & 5 deletions data/models/solicitation.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,6 @@ def clean(self):
"Une demande traitée doit l'être par quelqu'un ET à une date spécifiée ET par une action spécifique."
)

@property
def personal_message_for_mail(self) -> str:
"""Permet d'ajouter les messages personnels dans le corps d'un message d'email"""
return f"Iel a ajouté ce message : «{self.personal_msg}»." if self.personal_msg else ""

def save(self, *args, **kwargs):
"""Surchargée pour appeler un hook optionnel à la création de l'objet, défini dans la classe enfant"""
is_adding = self._state.adding
Expand Down Expand Up @@ -119,6 +114,7 @@ def create_hook(self):
"COMPANY_NAME": self.company.social_name,
"COMPANY_ID": self.company.id,
"ADMIN_LINK": f"{get_base_url()}admin/",
"PERSONAL_MESSAGE": self.personal_msg,
},
recipient.email,
recipient.get_full_name(),
Expand Down Expand Up @@ -187,6 +183,7 @@ def create_hook(self):
"REQUESTER_NAME": self.sender.get_full_name(),
"COMPANY_NAME": self.company.social_name,
"REQUEST_LINK": f"{get_base_url()}gestion-des-collaborateurs/{self.company.id}",
"PERSONAL_MESSAGE": self.personal_msg,
},
recipient.email,
recipient.get_full_name(),
Expand Down
8 changes: 0 additions & 8 deletions data/tests/test_solicitation.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,3 @@ def test_soliciation_process_requires_all_process_field(self):
self.solicitation.processed_at = timezone.now()
with self.assertRaises(ValidationError):
self.solicitation.save()

def test_personnal_message(self):
# empty personnal message
solicitation = SupervisionClaimFactory(personal_msg="")
self.assertEqual(solicitation.personal_message_for_mail, "")
# non-empty personnal message
solicitation = SupervisionClaimFactory(personal_msg="Svp ajoutez-moi !")
self.assertEqual(solicitation.personal_message_for_mail, "Iel a ajouté ce message : «Svp ajoutez-moi !».")

0 comments on commit 9cc4a97

Please sign in to comment.