From 234a9eede16ddd6db4c2efc81cd62f8bfb56c942 Mon Sep 17 00:00:00 2001 From: Raphael Odini Date: Mon, 29 Apr 2024 15:29:30 +0200 Subject: [PATCH 1/2] New TemplateTransactional source choice: Django --- lemarche/conversations/constants.py | 2 ++ ...0014_alter_templatetransactional_source.py | 22 +++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 lemarche/conversations/migrations/0014_alter_templatetransactional_source.py diff --git a/lemarche/conversations/constants.py b/lemarche/conversations/constants.py index 01019515b..e625b1d14 100644 --- a/lemarche/conversations/constants.py +++ b/lemarche/conversations/constants.py @@ -2,8 +2,10 @@ SOURCE_MAILJET = "MAILJET" SOURCE_BREVO = "BREVO" +SOURCE_DJANGO = "DJANGO" SOURCE_CHOICES = ( (SOURCE_MAILJET, "Mailjet"), (SOURCE_BREVO, "Brevo"), + (SOURCE_DJANGO, "Django"), ) diff --git a/lemarche/conversations/migrations/0014_alter_templatetransactional_source.py b/lemarche/conversations/migrations/0014_alter_templatetransactional_source.py new file mode 100644 index 000000000..758a0d3ea --- /dev/null +++ b/lemarche/conversations/migrations/0014_alter_templatetransactional_source.py @@ -0,0 +1,22 @@ +# Generated by Django 4.2.9 on 2024-04-29 13:28 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("conversations", "0013_templatetransactional_email_fields"), + ] + + operations = [ + migrations.AlterField( + model_name="templatetransactional", + name="source", + field=models.CharField( + blank=True, + choices=[("MAILJET", "Mailjet"), ("BREVO", "Brevo"), ("DJANGO", "Django")], + max_length=20, + verbose_name="Source", + ), + ), + ] From 5c14b1f83cf1763c84c7b101f8ba6c3bc3a130da Mon Sep 17 00:00:00 2001 From: Raphael Odini Date: Mon, 29 Apr 2024 15:34:39 +0200 Subject: [PATCH 2/2] Show code in admin --- lemarche/conversations/admin.py | 2 +- lemarche/conversations/models.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lemarche/conversations/admin.py b/lemarche/conversations/admin.py index 18c4cfe1b..969e9bb64 100644 --- a/lemarche/conversations/admin.py +++ b/lemarche/conversations/admin.py @@ -134,7 +134,7 @@ def data_display(self, conversation: Conversation = None): @admin.register(TemplateTransactional, site=admin_site) class TemplateTransactionalAdmin(admin.ModelAdmin): - list_display = ["id", "name", "mailjet_id", "brevo_id", "source", "is_active", "created_at", "updated_at"] + list_display = ["id", "name", "code", "mailjet_id", "brevo_id", "source", "is_active", "created_at", "updated_at"] search_fields = ["id", "name", "code", "mailjet_id", "brevo_id"] readonly_fields = ["code", "email_subject", "email_from_email", "email_from_name", "created_at", "updated_at"] diff --git a/lemarche/conversations/models.py b/lemarche/conversations/models.py index ea867c5c7..8c8249253 100644 --- a/lemarche/conversations/models.py +++ b/lemarche/conversations/models.py @@ -223,6 +223,8 @@ class Meta: verbose_name_plural = "Templates transactionnels" def __str__(self): + if self.code: + return f"{self.name} ({self.code})" return self.name @property