Skip to content

Commit

Permalink
New Siae property contact_email_name_display
Browse files Browse the repository at this point in the history
  • Loading branch information
raphodn committed Jul 3, 2024
1 parent 834206e commit c274382
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
4 changes: 4 additions & 0 deletions lemarche/siaes/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1083,6 +1083,10 @@ def contact_short_name(self):
return f"{self.contact_first_name.upper()[:1]}. {self.contact_last_name.upper()}"
return ""

@property
def contact_email_name_display(self):
return self.contact_full_name or self.name_display

@property
def contact_phone_display(self):
return phone_number_display(self.contact_phone)
Expand Down
8 changes: 5 additions & 3 deletions lemarche/www/conversations/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@

def send_first_email_from_conversation(conv: Conversation):
siae: Siae = conv.siae
from_email = f"{conv.sender_first_name} {conv.sender_last_name} <{conv.sender_email_buyer_encoded}>"
from_name = f"{conv.sender_first_name} {conv.sender_last_name}"
from_email = f"{from_name} <{conv.sender_email_buyer_encoded}>"

sender_company_name = ""
if conv.sender_user and conv.sender_user.company_name:
Expand All @@ -38,7 +39,8 @@ def send_email_from_conversation(
):
if user_kind == Conversation.USER_KIND_SENDER_TO_SIAE:
# from the buyer to the siae
from_email = f"{conv.sender_first_name} {conv.sender_last_name} <{conv.sender_email_buyer_encoded}>"
from_name = f"{conv.sender_first_name} {conv.sender_last_name}"
from_email = f"{from_name} <{conv.sender_email_buyer_encoded}>"
send_mail_async(
email_subject=email_subject,
email_body=email_body + DISCLAIMER_ATTACHMENTS,
Expand All @@ -49,7 +51,7 @@ def send_email_from_conversation(
elif user_kind == Conversation.USER_KIND_SENDER_TO_BUYER:
# from the siae to the buyer
siae: Siae = conv.siae
from_email = f"{siae.contact_full_name} <{conv.sender_email_siae_encoded}>"
from_email = f"{siae.contact_email_name_display} <{conv.sender_email_siae_encoded}>"
send_mail_async(
email_subject=email_subject,
email_body=email_body + DISCLAIMER_ATTACHMENTS,
Expand Down
6 changes: 3 additions & 3 deletions lemarche/www/tenders/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def send_tender_email_to_siae(tender: Tender, siae: Siae, email_subject: str, re
recipient_list = whitelist_recipient_list([email_to])
if len(recipient_list):
recipient_email = recipient_list[0]
recipient_name = siae.contact_full_name
recipient_name = siae.contact_email_name_display

tender_url = f"{get_object_share_url(tender)}?siae_id={siae.id}"
tender_not_interested_url = f"{get_object_share_url(tender)}?siae_id={siae.id}&not_interested=True"
Expand Down Expand Up @@ -273,7 +273,7 @@ def send_tender_contacted_reminder_email_to_siae(tendersiae: TenderSiae, email_t
recipient_list = whitelist_recipient_list([tendersiae.siae.contact_email])
if len(recipient_list):
recipient_email = recipient_list[0]
recipient_name = tendersiae.tender.author.full_name
recipient_name = tendersiae.siae.contact_email_name_display

variables = {
"SIAE_CONTACT_FIRST_NAME": tendersiae.siae.contact_first_name,
Expand Down Expand Up @@ -348,7 +348,7 @@ def send_tender_interested_reminder_email_to_siae(
recipient_list = whitelist_recipient_list([tendersiae.siae.contact_email])
if len(recipient_list):
recipient_email = recipient_list[0]
recipient_name = tendersiae.tender.author.full_name
recipient_name = tendersiae.siae.contact_email_name_display

variables = {
"SIAE_CONTACT_FIRST_NAME": tendersiae.siae.contact_first_name,
Expand Down

0 comments on commit c274382

Please sign in to comment.