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..c8dc94274 --- /dev/null +++ b/lemarche/tenders/migrations/0094_add_templatetransactional_tender_author_commercial_partners.py @@ -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), + ] diff --git a/lemarche/www/dashboard_siaes/views.py b/lemarche/www/dashboard_siaes/views.py index 242ddb94a..4b9987d12 100644 --- a/lemarche/www/dashboard_siaes/views.py +++ b/lemarche/www/dashboard_siaes/views.py @@ -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é {cleaned_data['sector_group']} a été crée avec succès.") + return mark_safe(f"Votre activité {cleaned_data['sector_group']} a été créée avec succès.") class SiaeEditActivitiesEditView(SiaeMemberRequiredMixin, SuccessMessageMixin, UpdateView): 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]