Skip to content

Commit

Permalink
Ajout de tender_id en argument de 'add_to_contact_list'
Browse files Browse the repository at this point in the history
  • Loading branch information
chloend committed Oct 24, 2024
1 parent 333aded commit 5dddd25
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lemarche/utils/emails.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,19 @@ def whitelist_recipient_list(recipient_list):
return [email for email in recipient_list if (email and email.endswith("beta.gouv.fr"))]


def add_to_contact_list(user, type: str, source: str = user_constants.SOURCE_SIGNUP_FORM):
def add_to_contact_list(user, type: str, tender_id: int = None, source: str = user_constants.SOURCE_SIGNUP_FORM):
"""Add user to contactlist
Args:
user (User): the user how will be added in the contact list
type (String): "signup", OR "buyer_download" or "buyer_search" else raise ValueError
"""
contact_list_id = None
tender_id = user.tenders.first().id if user.tenders.exists() else None
if type == "signup":
contact_list_id = api_mailjet.get_mailjet_cl_on_signup(user, source)
if user.kind == user.KIND_BUYER:
api_brevo.create_contact(user=user, list_id=settings.BREVO_CL_SIGNUP_BUYER_ID)
api_brevo.create_contact(user=user, list_id=settings.BREVO_CL_SIGNUP_BUYER_ID, tender_id=tender_id)
elif user.kind == user.KIND_SIAE:
api_brevo.create_contact(user=user, list_id=settings.BREVO_CL_SIGNUP_SIAE_ID)
elif type == "buyer_search":
Expand Down

0 comments on commit 5dddd25

Please sign in to comment.