Skip to content

Commit

Permalink
Add source & is_active fields
Browse files Browse the repository at this point in the history
  • Loading branch information
raphodn committed Dec 14, 2023
1 parent 2696afb commit 6dec600
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lemarche/conversations/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
8 changes: 8 additions & 0 deletions lemarche/conversations/constants.py
Original file line number Diff line number Diff line change
@@ -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"),
)
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
),
),
]
7 changes: 7 additions & 0 deletions lemarche/conversations/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 6dec600

Please sign in to comment.