diff --git a/lemarche/conversations/admin.py b/lemarche/conversations/admin.py index f865d1fc5..0de55034e 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", "created_at", "updated_at"] + list_display = ["id", "name", "mailjet_id", "brevo_id", "source", "is_active", "created_at", "updated_at"] search_fields = ["id", "name", "mailjet_id", "brevo_id"] readonly_fields = ["created_at", "updated_at"] diff --git a/lemarche/conversations/constants.py b/lemarche/conversations/constants.py index e56280a17..01019515b 100644 --- a/lemarche/conversations/constants.py +++ b/lemarche/conversations/constants.py @@ -1 +1,9 @@ ATTRIBUTES_TO_SAVE_FOR_INBOUND = ["From", "To", "CC", "ReplyTo", "SentAtDate", "Attachments"] + +SOURCE_MAILJET = "MAILJET" +SOURCE_BREVO = "BREVO" + +SOURCE_CHOICES = ( + (SOURCE_MAILJET, "Mailjet"), + (SOURCE_BREVO, "Brevo"), +) diff --git a/lemarche/conversations/migrations/0012_templatetransactional.py b/lemarche/conversations/migrations/0012_templatetransactional.py index 42b81aa1a..f2a9b4997 100644 --- a/lemarche/conversations/migrations/0012_templatetransactional.py +++ b/lemarche/conversations/migrations/0012_templatetransactional.py @@ -21,7 +21,6 @@ class Migration(migrations.Migration): models.IntegerField( blank=True, db_index=True, - max_length=20, null=True, unique=True, verbose_name="Identifiant Mailjet", @@ -32,7 +31,6 @@ class Migration(migrations.Migration): models.IntegerField( blank=True, db_index=True, - max_length=20, null=True, unique=True, verbose_name="Identifiant Brevo", diff --git a/lemarche/conversations/migrations/0013_templatetransactional_source_and_is_active.py b/lemarche/conversations/migrations/0013_templatetransactional_source_and_is_active.py new file mode 100644 index 000000000..be0b6968a --- /dev/null +++ b/lemarche/conversations/migrations/0013_templatetransactional_source_and_is_active.py @@ -0,0 +1,24 @@ +# Generated by Django 4.2.2 on 2023-12-14 10:13 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("conversations", "0012_templatetransactional"), + ] + + operations = [ + migrations.AddField( + model_name="templatetransactional", + name="is_active", + field=models.BooleanField(default=False, verbose_name="Actif"), + ), + migrations.AddField( + model_name="templatetransactional", + name="source", + field=models.CharField( + blank=True, choices=[("MAILJET", "Mailjet"), ("BREVO", "Brevo")], max_length=20, verbose_name="Source" + ), + ), + ] diff --git a/lemarche/conversations/models.py b/lemarche/conversations/models.py index af3119c90..52d601046 100644 --- a/lemarche/conversations/models.py +++ b/lemarche/conversations/models.py @@ -8,6 +8,8 @@ from django_extensions.db.fields import ShortUUIDField from shortuuid import uuid +from lemarche.conversations import constants as conversation_constants + class ConversationQuerySet(models.QuerySet): def has_answer(self): @@ -192,6 +194,11 @@ class TemplateTransactional(models.Model): ) 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 + ) + is_active = models.BooleanField(verbose_name="Actif", default=False) + created_at = models.DateTimeField(verbose_name="Date de création", default=timezone.now) updated_at = models.DateTimeField(verbose_name="Date de modification", auto_now=True)