diff --git a/lemarche/tenders/admin.py b/lemarche/tenders/admin.py index 17c13311b..d5ed59c89 100644 --- a/lemarche/tenders/admin.py +++ b/lemarche/tenders/admin.py @@ -292,6 +292,7 @@ class TenderAdmin(FieldsetsInlineMixin, admin.ModelAdmin): "contact_phone", "response_kind", "response_is_anonymous", + "contact_notification_disabled", ), }, ), diff --git a/lemarche/tenders/migrations/0072_tender_contact_notification_disabled.py b/lemarche/tenders/migrations/0072_tender_contact_notification_disabled.py new file mode 100644 index 000000000..9a5cdde4a --- /dev/null +++ b/lemarche/tenders/migrations/0072_tender_contact_notification_disabled.py @@ -0,0 +1,21 @@ +# Generated by Django 4.2.9 on 2024-01-31 09:21 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("tenders", "0071_tender_partner_approch_id"), + ] + + operations = [ + migrations.AddField( + model_name="tender", + name="contact_notification_disabled", + field=models.BooleanField( + default=False, + help_text="Champ renseigné par un ADMIN", + verbose_name="Le contact ne souhaite plus être contacté pour ce besoin", + ), + ), + ] diff --git a/lemarche/tenders/models.py b/lemarche/tenders/models.py index 3bf0695b5..a3f3b259c 100644 --- a/lemarche/tenders/models.py +++ b/lemarche/tenders/models.py @@ -335,6 +335,11 @@ class Tender(models.Model): max_length=255, blank=True, ) + contact_notification_disabled = models.BooleanField( + verbose_name="Le contact ne souhaite plus être contacté pour ce besoin", + help_text=ADMIN_FIELD_HELP_TEXT, + default=False, + ) sectors = models.ManyToManyField( "sectors.Sector", diff --git a/lemarche/www/tenders/tasks.py b/lemarche/www/tenders/tasks.py index 9da674537..4450982c2 100644 --- a/lemarche/www/tenders/tasks.py +++ b/lemarche/www/tenders/tasks.py @@ -371,7 +371,7 @@ def send_confirmation_published_email_to_author(tender: Tender, nb_matched_siaes """ email_subject = f"Votre {tender.get_kind_display().lower()} a été publié !" recipient_list = whitelist_recipient_list([tender.author.email]) - if recipient_list: + if recipient_list and not tender.contact_notification_disabled: recipient_email = recipient_list[0] if recipient_list else "" recipient_name = tender.author.full_name @@ -447,7 +447,7 @@ def send_siae_interested_email_to_author(tender: Tender): if should_send_email: recipient_list = whitelist_recipient_list([tender.author.email]) # tender.contact_email ? - if recipient_list: + if recipient_list and not tender.contact_notification_disabled: recipient_email = recipient_list[0] if recipient_list else "" recipient_name = tender.author.full_name @@ -508,7 +508,7 @@ def notify_admin_tender_created(tender: Tender): def send_author_incremental_2_days_email(tender: Tender): email_subject = f"Concernant votre {tender.get_kind_display()} sur le Marché de l'inclusion" recipient_list = whitelist_recipient_list([tender.author.email]) - if recipient_list: + if recipient_list and not tender.contact_notification_disabled: recipient_email = recipient_list[0] if recipient_list else "" recipient_name = tender.author.full_name @@ -542,7 +542,7 @@ def send_author_incremental_2_days_email(tender: Tender): def send_tenders_author_feedback_or_survey(tender: Tender, kind="feedback_30d"): email_subject = f"Suite à votre {tender.get_kind_display().lower()}" recipient_list = whitelist_recipient_list([tender.author.email]) - if recipient_list: + if recipient_list and not tender.contact_notification_disabled: recipient_email = recipient_list[0] if recipient_list else "" recipient_name = tender.author.full_name