Skip to content

Commit

Permalink
feat(Besoin): Ajout d'un template de mail transactionnel quand le bes…
Browse files Browse the repository at this point in the history
…oin est suivi par un partenaire commercial (#1533)
  • Loading branch information
SebastienReuiller authored Nov 21, 2024
1 parent 810669e commit 4939bf0
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from django.db import migrations


def create_template(apps, schema_editor):
TemplateTransactional = apps.get_model("conversations", "TemplateTransactional")
TemplateTransactional.objects.create(
name="Dépôt de besoin : auteur : notification quand son besoin a été validé et pris en charge par les partenaires commerciaux",
code="TENDERS_AUTHOR_CONFIRMATION_VALIDATED_COMMERCIAL_PARTNERS",
description="Envoyé à l'auteur du besoin lorsque son besoin a été validé et qu'il n'est pas envoyé aux structures mais proposé aux partenaires commerciaux",
)


def delete_template(apps, schema_editor):
TemplateTransactional = apps.get_model("conversations", "TemplateTransactional")
TemplateTransactional.objects.get(code="TENDERS_AUTHOR_CONFIRMATION_VALIDATED_COMMERCIAL_PARTNERS").delete()


class Migration(migrations.Migration):
dependencies = [
("tenders", "0093_alter_tender_send_to_commercial_partners_only"),
]

operations = [
migrations.RunPython(create_template, reverse_code=delete_template),
]
2 changes: 1 addition & 1 deletion lemarche/www/dashboard_siaes/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ def get_success_url(self):
return reverse_lazy("dashboard_siaes:siae_edit_activities", args=[self.kwargs.get("slug")])

def get_success_message(self, cleaned_data):
return mark_safe(f"Votre activité <strong>{cleaned_data['sector_group']}</strong> a été crée avec succès.")
return mark_safe(f"Votre activité <strong>{cleaned_data['sector_group']}</strong> a été créée avec succès.")


class SiaeEditActivitiesEditView(SiaeMemberRequiredMixin, SuccessMessageMixin, UpdateView):
Expand Down
8 changes: 7 additions & 1 deletion lemarche/www/tenders/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,13 @@ def send_confirmation_published_email_to_author(tender: Tender):
"""
Send email to the author when the tender is published to the siaes
"""
email_template = TemplateTransactional.objects.get(code="TENDERS_AUTHOR_CONFIRMATION_VALIDATED")

template_code = (
"TENDERS_AUTHOR_CONFIRMATION_VALIDATED_COMMERCIAL_PARTNERS"
if tender.send_to_commercial_partners_only
else "TENDERS_AUTHOR_CONFIRMATION_VALIDATED"
)
email_template = TemplateTransactional.objects.get(code=template_code)
recipient_list = whitelist_recipient_list([tender.author.email])
if len(recipient_list):
recipient_email = recipient_list[0]
Expand Down

0 comments on commit 4939bf0

Please sign in to comment.