diff --git a/lemarche/siaes/models.py b/lemarche/siaes/models.py index 30e35e8fc..e3c159003 100644 --- a/lemarche/siaes/models.py +++ b/lemarche/siaes/models.py @@ -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) diff --git a/lemarche/www/conversations/tasks.py b/lemarche/www/conversations/tasks.py index 11447b7de..5f7875884 100644 --- a/lemarche/www/conversations/tasks.py +++ b/lemarche/www/conversations/tasks.py @@ -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: @@ -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, @@ -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, diff --git a/lemarche/www/tenders/tasks.py b/lemarche/www/tenders/tasks.py index 95bcfd306..243ddfa61 100644 --- a/lemarche/www/tenders/tasks.py +++ b/lemarche/www/tenders/tasks.py @@ -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}¬_interested=True" @@ -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, @@ -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,