From ba19a1a90971dded1e2bc30744526aecc2ba197e Mon Sep 17 00:00:00 2001 From: Alejandro Sanchez Date: Tue, 24 Sep 2024 18:23:53 +0000 Subject: [PATCH] update formentry.status to include MANUALLY_PERSISTED --- .../0087_alter_formentry_storage_status.py | 29 +++++++++++++++++++ breathecode/marketing/models.py | 8 ++++- .../activecampaign/actions/deal_add.py | 4 ++- 3 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 breathecode/marketing/migrations/0087_alter_formentry_storage_status.py diff --git a/breathecode/marketing/migrations/0087_alter_formentry_storage_status.py b/breathecode/marketing/migrations/0087_alter_formentry_storage_status.py new file mode 100644 index 000000000..4b5a5597a --- /dev/null +++ b/breathecode/marketing/migrations/0087_alter_formentry_storage_status.py @@ -0,0 +1,29 @@ +# Generated by Django 5.1.1 on 2024-09-24 16:29 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("marketing", "0086_coursetranslation_landing_variables"), + ] + + operations = [ + migrations.AlterField( + model_name="formentry", + name="storage_status", + field=models.CharField( + choices=[ + ("PENDING", "Pending"), + ("PERSISTED", "Persisted"), + ("REJECTED", "Rejected"), + ("DUPLICATED", "Duplicated"), + ("ERROR", "Error"), + ], + default="PENDING", + help_text="MANUALLY_PERSISTED means it was copy pasted into active campaign", + max_length=15, + ), + ), + ] diff --git a/breathecode/marketing/models.py b/breathecode/marketing/models.py index 571614323..90f166287 100644 --- a/breathecode/marketing/models.py +++ b/breathecode/marketing/models.py @@ -283,6 +283,7 @@ def save(self, *args, **kwargs): DUPLICATED = "DUPLICATED" REJECTED = "REJECTED" ERROR = "ERROR" +MANUAL = "MANUALLY_PERSISTED" STORAGE_STATUS = ( (PENDING, "Pending"), (PERSISTED, "Persisted"), @@ -402,7 +403,12 @@ def __init__(self, *args, **kwargs): sex = models.CharField(max_length=15, null=True, default=None, blank=True, help_text="M=male,F=female,O=other") # is it saved into active campaign? - storage_status = models.CharField(max_length=15, choices=STORAGE_STATUS, default=PENDING) + storage_status = models.CharField( + max_length=15, + choices=STORAGE_STATUS, + default=PENDING, + help_text="MANUALLY_PERSISTED means it was copy pasted into active campaign", + ) storage_status_text = models.CharField( default="", blank=True, diff --git a/breathecode/services/activecampaign/actions/deal_add.py b/breathecode/services/activecampaign/actions/deal_add.py index 9444a9a23..136913ec5 100644 --- a/breathecode/services/activecampaign/actions/deal_add.py +++ b/breathecode/services/activecampaign/actions/deal_add.py @@ -34,7 +34,9 @@ def deal_add(self, webhook, payload: dict, acp_ids): if entry is None and "deal[contact_email]" in payload: entry = ( FormEntry.objects.filter( - email=payload["deal[contact_email]"], ac_deal_id__isnull=True, storage_status="PERSISTED" + email=payload["deal[contact_email]"], + ac_deal_id__isnull=True, + storage_status__in=["PERSISTED", "MANUALLY_PERSISTED"], ) .order_by("-created_at") .first()