(self)
Sends a reminder email to the emails specified in the accounting
        contacts that the subscription will end on the specified end date.
Sends a reminder email to the emails specified in the accounting
        contacts that the subscription will end on the specified end date.
Sends a reminder email to the emails specified in the accounting contacts that the subscription will end on the specified end date .
def send_ending_reminder_email(self):
        """
        Sends a reminder email to the emails specified in the accounting
        contacts that the subscription will end on the specified end date.
        """
        if self.date_end is None:
            raise SubscriptionReminderError(
                "This subscription has no end date."
            )
        if self.plan_version.plan.edition == SoftwarePlanEdition.PAUSED:
            # never send a subscription ending email for Paused subscriptions...
            return

        today = datetime.date.today()
        num_days_left = (self.date_end - today).days

        domain_name = self.subscriber.domain
        context = self.ending_reminder_context
        subject = context['subject']

        template = self.ending_reminder_email_html
        template_plaintext = self.ending_reminder_email_text
        email_html = render_to_string(template, context)
        email_plaintext = render_to_string(template_plaintext, context)
        bcc = [settings.ACCOUNTS_EMAIL] if not self.is_trial else []
        if self.account.dimagi_contact is not None:
            bcc.append(self.account.dimagi_contact)
        for email in self._reminder_email_contacts(domain_name):
            send_html_email_async.delay(
                subject, email, email_html,
                text_content=email_plaintext,
                email_from=get_dimagi_from_email(),
                bcc=bcc,
            )
            log_accounting_info(
                "Sent %(days_left)s-day subscription reminder "
                "email for %(domain)s to %(email)s." % {
                    'days_left': num_days_left,
                    'domain': domain_name,
                    'email': email,
                }
            )
def send_ending_reminder_email ( self ) : if self . date_end is None : raise SubscriptionReminderError ( "This subscription has no end date." ) if self . plan_version . plan . edition == SoftwarePlanEdition . PAUSED : # never send a subscription ending email for Paused subscriptions... return today = datetime . date . today ( ) num_days_left = ( self . date_end - today ) . days domain_name = self . subscriber . domain context = self . ending_reminder_context subject = context [ 'subject' ] template = self . ending_reminder_email_html template_plaintext = self . ending_reminder_email_text email_html = render_to_string ( template , context ) email_plaintext = render_to_string ( template_plaintext , context ) bcc = [ settings . ACCOUNTS_EMAIL ] if not self . is_trial else [ ] if self . account . dimagi_contact is not None : bcc . append ( self . account . dimagi_contact ) for email in self . _reminder_email_contacts ( domain_name ) : send_html_email_async . delay ( subject , email , email_html , text_content = email_plaintext , email_from = get_dimagi_from_email ( ) , bcc = bcc , ) log_accounting_info ( "Sent %(days_left)s-day subscription reminder " "email for %(domain)s to %(email)s." % { 'days_left' : num_days_left , 'domain' : domain_name , 'email' : email , } )