def send_siae_user_request_reminder_3_days_email_to_initiator( siae_user_request): email_subject = EMAIL_SUBJECT_PREFIX + "Rattachement sans réponse" recipient_list = whitelist_recipient_list( [siae_user_request.initiator.email]) recipient_email = recipient_list[0] if recipient_list else "" recipient_name = siae_user_request.initiator.full_name variables = { "ASSIGNEE_FULL_NAME": siae_user_request.assignee.full_name, "INITIATOR_FULL_NAME": siae_user_request.initiator.full_name, "SIAE_NAME": siae_user_request.siae.name_display, } api_mailjet.send_transactional_email_with_template( template_id=settings. MAILJET_SIAEUSERREQUEST_REMINDER_1_INITIATOR_TEMPLATE_ID, subject=email_subject, recipient_email=recipient_email, recipient_name=recipient_name, variables=variables, ) # log email log_item = { "action": "email_sent", "email_to": recipient_email, "email_subject": email_subject, # "email_body": email_body, "email_timestamp": timezone.now().isoformat(), } siae_user_request.logs.append(log_item) siae_user_request.save()
def send_siae_user_request_response_email_to_initiator(siae_user_request, response=None): """ Send request response (True or False) to the initial user """ email_subject_text = "Accéder à votre structure" if response else "Rattachement refusé" email_subject = EMAIL_SUBJECT_PREFIX + email_subject_text email_template_id = ( settings. MAILJET_SIAEUSERREQUEST_INITIATOR_RESPONSE_POSITIVE_TEMPLATE_ID if response else settings. MAILJET_SIAEUSERREQUEST_INITIATOR_RESPONSE_NEGATIVE_TEMPLATE_ID) recipient_list = whitelist_recipient_list( [siae_user_request.initiator.email]) recipient_email = recipient_list[0] if recipient_list else "" recipient_name = siae_user_request.initiator.full_name variables = { "ASSIGNEE_FULL_NAME": siae_user_request.assignee.full_name, "INITIATOR_FULL_NAME": siae_user_request.initiator.full_name, "SIAE_NAME": siae_user_request.siae.name_display, "DASHBOARD_URL": f"https://{get_domain_url()}{reverse_lazy('dashboard:home')}", } api_mailjet.send_transactional_email_with_template( template_id=email_template_id, subject=email_subject, recipient_email=recipient_email, recipient_name=recipient_name, variables=variables, ) # log email log_item = { "action": "email_sent", "email_to": recipient_email, "email_subject": email_subject, # "email_body": email_body, "email_timestamp": timezone.now().isoformat(), } siae_user_request.logs.append(log_item) siae_user_request.save()
def send_siae_interested_email_to_author(tender: Tender): """ The author is notified (by intervals) when new Siaes show interest (contact_click_date set) Intervals: - first Siae - every 5 Siae """ tender_siae_contact_click_count = TenderSiae.objects.filter( tender=tender, contact_click_date__isnull=False).count() if (tender_siae_contact_click_count > 0) and (tender_siae_contact_click_count < 50): if (tender_siae_contact_click_count == 1) or (tender_siae_contact_click_count % 5 == 0): if tender_siae_contact_click_count == 1: email_subject = EMAIL_SUBJECT_PREFIX + "Une première structure intéressée !" template_id = settings.MAILJET_TENDERS_SIAE_INTERESTED_1_TEMPLATE_ID else: email_subject = EMAIL_SUBJECT_PREFIX + "5 nouvelles structures intéressées !" template_id = settings.MAILJET_TENDERS_SIAE_INTERESTED_5_TEMPLATE_ID recipient_list = whitelist_recipient_list( [tender.author.email]) # tender.contact_email ? if recipient_list: recipient_email = recipient_list[0] if recipient_list else "" recipient_name = tender.author.full_name variables = { "TENDER_AUTHOR_FIRST_NAME": tender.author.first_name, "TENDER_TITLE": tender.title, "TENDER_SIAE_INTERESTED_LIST_URL": f"{get_share_url_object(tender)}/structures-interessees", # noqa } api_mailjet.send_transactional_email_with_template( template_id=template_id, subject=email_subject, recipient_email=recipient_email, recipient_name=recipient_name, variables=variables, )
def send_siae_user_request_email_to_assignee(siae_user_request): """ Send request to the assignee """ email_subject = EMAIL_SUBJECT_PREFIX + "Nouveau collaborateur" recipient_list = whitelist_recipient_list( [siae_user_request.assignee.email]) recipient_email = recipient_list[0] if recipient_list else "" recipient_name = siae_user_request.assignee.full_name variables = { "ASSIGNEE_FULL_NAME": siae_user_request.assignee.full_name, "INITIATOR_FULL_NAME": siae_user_request.initiator.full_name, "SIAE_NAME": siae_user_request.siae.name_display, "SIAE_USERS_URL": f"https://{get_domain_url()}{reverse_lazy('dashboard:siae_users', args=[siae_user_request.siae.slug])}", # noqa } api_mailjet.send_transactional_email_with_template( template_id=settings.MAILJET_SIAEUSERREQUEST_ASSIGNEE_TEMPLATE_ID, subject=email_subject, recipient_email=recipient_email, recipient_name=recipient_name, variables=variables, ) # log email log_item = { "action": "email_sent", "email_to": recipient_email, "email_subject": email_subject, # "email_body": email_body, "email_timestamp": timezone.now().isoformat(), } siae_user_request.logs.append(log_item) siae_user_request.save()
def send_tender_email_to_siae(tender: Tender, siae: Siae): email_subject = f"{EMAIL_SUBJECT_PREFIX}{tender.author.company_name} a besoin de vous sur le marché de l'inclusion" recipient_list = whitelist_recipient_list([siae.contact_email]) if recipient_list: recipient_email = recipient_list[0] if recipient_list else "" recipient_name = siae.contact_full_name variables = { "SIAE_CONTACT_FIRST_NAME": siae.contact_first_name, "TENDER_AUTHOR_COMPANY": tender.author.company_name, "TENDER_KIND": tender.get_kind_display(), "TENDER_SECTORS": tender.get_sectors_names, "TENDER_PERIMETERS": tender.get_perimeters_names, "TENDER_URL": get_share_url_object(tender), } api_mailjet.send_transactional_email_with_template( template_id=settings.MAILJET_TENDERS_PRESENTATION_TEMPLATE_ID, subject=email_subject, recipient_email=recipient_email, recipient_name=recipient_name, variables=variables, )