From 1646a33c4938772dad32e1f91f23d5424810f451 Mon Sep 17 00:00:00 2001 From: Raphael Odini Date: Tue, 9 Jan 2024 10:52:18 +0100 Subject: [PATCH] Emails : ajout de quelques champs de configuration de l'e-mail dans les templates (#1024) * TemplateTransactional: new fields describing email content * Add to admin --- lemarche/conversations/admin.py | 9 +++++- ...0013_templatetransactional_email_fields.py | 29 +++++++++++++++++++ lemarche/conversations/models.py | 6 +++- 3 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 lemarche/conversations/migrations/0013_templatetransactional_email_fields.py diff --git a/lemarche/conversations/admin.py b/lemarche/conversations/admin.py index 08d622874..18c4cfe1b 100644 --- a/lemarche/conversations/admin.py +++ b/lemarche/conversations/admin.py @@ -137,4 +137,11 @@ class TemplateTransactionalAdmin(admin.ModelAdmin): list_display = ["id", "name", "mailjet_id", "brevo_id", "source", "is_active", "created_at", "updated_at"] search_fields = ["id", "name", "code", "mailjet_id", "brevo_id"] - readonly_fields = ["code", "created_at", "updated_at"] + readonly_fields = ["code", "email_subject", "email_from_email", "email_from_name", "created_at", "updated_at"] + + fieldsets = ( + (None, {"fields": ("name", "code", "description")}), + ("Paramètres de l'e-mail", {"fields": ("email_subject", "email_from_email", "email_from_name")}), + ("Paramètres d'envoi", {"fields": ("mailjet_id", "brevo_id", "source", "is_active")}), + ("Dates", {"fields": ("created_at", "updated_at")}), + ) diff --git a/lemarche/conversations/migrations/0013_templatetransactional_email_fields.py b/lemarche/conversations/migrations/0013_templatetransactional_email_fields.py new file mode 100644 index 000000000..75bbf1015 --- /dev/null +++ b/lemarche/conversations/migrations/0013_templatetransactional_email_fields.py @@ -0,0 +1,29 @@ +# Generated by Django 4.2.2 on 2023-12-19 13:41 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("conversations", "0012_templatetransactional"), + ] + + operations = [ + migrations.AddField( + model_name="templatetransactional", + name="email_from_email", + field=models.EmailField( + blank=True, max_length=254, null=True, verbose_name="E-mail : expéditeur (e-mail)" + ), + ), + migrations.AddField( + model_name="templatetransactional", + name="email_from_name", + field=models.CharField(blank=True, max_length=255, null=True, verbose_name="E-mail : expéditeur (nom)"), + ), + migrations.AddField( + model_name="templatetransactional", + name="email_subject", + field=models.CharField(blank=True, max_length=255, null=True, verbose_name="E-mail : objet"), + ), + ] diff --git a/lemarche/conversations/models.py b/lemarche/conversations/models.py index 27165e7aa..ea867c5c7 100644 --- a/lemarche/conversations/models.py +++ b/lemarche/conversations/models.py @@ -201,11 +201,15 @@ class TemplateTransactional(models.Model): verbose_name="Nom technique", max_length=255, unique=True, db_index=True, blank=True, null=True ) description = models.TextField(verbose_name="Description", blank=True) + + email_subject = models.CharField(verbose_name="E-mail : objet", max_length=255, blank=True, null=True) + email_from_email = models.EmailField(verbose_name="E-mail : expéditeur (e-mail)", blank=True, null=True) + email_from_name = models.CharField(verbose_name="E-mail : expéditeur (nom)", max_length=255, blank=True, null=True) + mailjet_id = models.IntegerField( verbose_name="Identifiant Mailjet", unique=True, db_index=True, blank=True, null=True ) brevo_id = models.IntegerField(verbose_name="Identifiant Brevo", unique=True, db_index=True, blank=True, null=True) - source = models.CharField( verbose_name="Source", max_length=20, choices=conversation_constants.SOURCE_CHOICES, blank=True )