(idp)
return email_context
Utility to generate metadata and render messages for an IdP certificate
    expiration reminder email.

    :param idp: IdentityProvider
    :return: Dict (parameters for sending email)
Utility to generate metadata and render messages for an IdP certificate
    expiration reminder email.
Utility to generate metadata and render messages for an IdP certificate expiration reminder email .
def get_idp_cert_expiration_email_context(idp):
    """
    Utility to generate metadata and render messages for an IdP certificate
    expiration reminder email.

    :param idp: IdentityProvider
    :return: Dict (parameters for sending email)
    """

    today = datetime.datetime.utcnow().date()
    exp_date = idp.date_idp_cert_expiration.date()
    num_days_left = (exp_date - today).days
    if num_days_left == 0:
        expires_on = _("today!")
    elif num_days_left == 1:
        expires_on = _("tomorrow!")
    else:
        expires_on = _(f"on {exp_date:{USER_DATE_FORMAT}}.")

    template_context = {
        "idp_name": idp.name,
        "expires_on": expires_on,
        "contact_email": settings.ACCOUNTS_EMAIL,
        "base_url": get_site_domain(),
    }
    subject = _(
        "CommCare Alert: Certificate for Identity Provider %(idp_name)s "
        "expires %(expires_on)s"
    ) % template_context
    body_html, body_txt = render_multiple_to_strings(
        template_context,
        "sso/email/idp_cert_expiring_reminder.html",
        "sso/email/idp_cert_expiring_reminder.txt",
    )
    email_context = {
        "subject": subject,
        "from": _(f"Dimagi CommCare Accounts <{settings.ACCOUNTS_EMAIL}>"),
        "to": idp.owner.enterprise_admin_emails,
        "bcc": [settings.ACCOUNTS_EMAIL],
        "html": body_html,
        "plaintext": body_txt,
    }
    if idp.owner.dimagi_contact:
        email_context["bcc"].append(idp.owner.dimagi_contact)
    return email_context
def get_idp_cert_expiration_email_context ( idp ) : today = datetime . datetime . utcnow ( ) . date ( ) exp_date = idp . date_idp_cert_expiration . date ( ) num_days_left = ( exp_date - today ) . days if num_days_left == 0 : expires_on = _ ( "today!" ) elif num_days_left == 1 : expires_on = _ ( "tomorrow!" ) else : expires_on = _ ( f"on {exp_date:{USER_DATE_FORMAT}}." ) template_context = { "idp_name" : idp . name , "expires_on" : expires_on , "contact_email" : settings . ACCOUNTS_EMAIL , "base_url" : get_site_domain ( ) , } subject = _ ( "CommCare Alert: Certificate for Identity Provider %(idp_name)s " "expires %(expires_on)s" ) % template_context body_html , body_txt = render_multiple_to_strings ( template_context , "sso/email/idp_cert_expiring_reminder.html" , "sso/email/idp_cert_expiring_reminder.txt" , ) email_context = { "subject" : subject , "from" : _ ( f"Dimagi CommCare Accounts <{settings.ACCOUNTS_EMAIL}>" ) , "to" : idp . owner . enterprise_admin_emails , "bcc" : [ settings . ACCOUNTS_EMAIL ] , "html" : body_html , "plaintext" : body_txt , } if idp . owner . dimagi_contact : email_context [ "bcc" ] . append ( idp . owner . dimagi_contact ) return email_context