From a855e7e5b5d31b7ab20aa7fef5acaa400530ede0 Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Tue, 14 Mar 2023 09:38:39 +0000 Subject: [PATCH] Make sending references configurable --- core/clients/platform.py | 3 ++- core/forms.py | 2 ++ core/migrations/0024_ad_send_reference.py | 18 ++++++++++++++++++ core/models.py | 2 ++ 4 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 core/migrations/0024_ad_send_reference.py diff --git a/core/clients/platform.py b/core/clients/platform.py index ef2da13..c7eb0ca 100644 --- a/core/clients/platform.py +++ b/core/clients/platform.py @@ -817,7 +817,8 @@ class LocalPlatformClient(ABC): ad_obj = self.instance.get_ad(ad_id) if ad_obj: await self.send_bank_details(currency, trade_id, ad_obj) - await self.send_reference(trade_id, reference) + if ad_obj.send_reference is True: + await self.send_reference(trade_id, reference) else: log.warning(f"Could not get ad object for {ad_id}.") # return diff --git a/core/forms.py b/core/forms.py index 3713714..af07158 100644 --- a/core/forms.py +++ b/core/forms.py @@ -160,6 +160,7 @@ class AdForm(RestrictedFormMixin, ModelForm): "platforms", "aggregators", "account_whitelist", + "send_reference", "visible", "enabled", ) @@ -175,6 +176,7 @@ class AdForm(RestrictedFormMixin, ModelForm): "platforms": "Enabled platforms for this ad", "aggregators": "Enabled aggregators for this ad", "account_whitelist": "List of account IDs to use, one per line.", + "send_reference": "Whether or not to send the reference on new trades.", "visible": "Whether or not this ad is visible.", "enabled": "Whether or not this ad is enabled.", } diff --git a/core/migrations/0024_ad_send_reference.py b/core/migrations/0024_ad_send_reference.py new file mode 100644 index 0000000..2ecfea2 --- /dev/null +++ b/core/migrations/0024_ad_send_reference.py @@ -0,0 +1,18 @@ +# Generated by Django 4.1.7 on 2023-03-14 09:36 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0023_alter_trade_linked'), + ] + + operations = [ + migrations.AddField( + model_name='ad', + name='send_reference', + field=models.BooleanField(default=True), + ), + ] diff --git a/core/models.py b/core/models.py index a163900..4dabe59 100644 --- a/core/models.py +++ b/core/models.py @@ -403,6 +403,8 @@ class Ad(models.Model): account_map = models.JSONField(default=dict) account_whitelist = models.TextField(null=True, blank=True) + send_reference = models.BooleanField(default=True) + visible = models.BooleanField(default=True) enabled = models.BooleanField(default=True)