From a4f6aaccfd2a9af36dde3b128a2d9baa4f458262 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Reuiller?= Date: Thu, 21 Nov 2024 11:12:16 +0100 Subject: [PATCH] add a specific template transactional for author when tender is following by commercial partner --- ...ional_tender_author_commercial_partners.py | 20 +++++++++++++++++++ lemarche/www/tenders/tasks.py | 8 +++++++- 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 lemarche/tenders/migrations/0094_add_templatetransactional_tender_author_commercial_partners.py diff --git a/lemarche/tenders/migrations/0094_add_templatetransactional_tender_author_commercial_partners.py b/lemarche/tenders/migrations/0094_add_templatetransactional_tender_author_commercial_partners.py new file mode 100644 index 000000000..672624dbd --- /dev/null +++ b/lemarche/tenders/migrations/0094_add_templatetransactional_tender_author_commercial_partners.py @@ -0,0 +1,20 @@ +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", + ) + + +class Migration(migrations.Migration): + dependencies = [ + ("tenders", "0093_alter_tender_send_to_commercial_partners_only"), + ] + + operations = [ + migrations.RunPython(create_template), + ] diff --git a/lemarche/www/tenders/tasks.py b/lemarche/www/tenders/tasks.py index 19fcc9df1..0a0c561b8 100644 --- a/lemarche/www/tenders/tasks.py +++ b/lemarche/www/tenders/tasks.py @@ -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]