Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dépôt de besoin : certains auteurs de besoins ne veulent plus recevoir d'e-mails #1064

Merged
merged 2 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lemarche/tenders/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ class TenderAdmin(FieldsetsInlineMixin, admin.ModelAdmin):
"contact_phone",
"response_kind",
"response_is_anonymous",
"contact_notification_disabled",
),
},
),
Expand Down
Original file line number Diff line number Diff line change
@@ -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",
),
),
]
5 changes: 5 additions & 0 deletions lemarche/tenders/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 4 additions & 4 deletions lemarche/www/tenders/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
Loading