(self, new_user, domain)
Sends an email to the old autopayer for this account telling them {new_user} is now the autopayer
Sends an email to the old autopayer for this account telling them {new_user} is now the autopayer
Sends an email to the old autopayer for this account telling them { new_user } is now the autopayer
def _send_autopay_card_removed_email(self, new_user, domain):
        """Sends an email to the old autopayer for this account telling them {new_user} is now the autopayer"""
        from corehq.apps.domain.views.accounting import EditExistingBillingAccountView
        old_username = self.auto_pay_user
        subject = _("Your card is no longer being used to auto-pay for {billing_account}").format(
            billing_account=self.name)

        old_web_user = WebUser.get_by_username(old_username)
        old_user_first_name = old_web_user.first_name if old_web_user else old_username
        email = old_web_user.get_email() if old_web_user else old_username

        context = {
            'new_user': new_user,
            'old_user_name': old_user_first_name,
            'billing_account_name': self.name,
            'billing_info_url': absolute_reverse(EditExistingBillingAccountView.urlname,
                                                 args=[domain]),
            'invoicing_contact_email': settings.INVOICING_CONTACT_EMAIL,
        }

        send_html_email_async(
            subject,
            email,
            render_to_string('accounting/email/autopay_card_removed.html', context),
            text_content=strip_tags(render_to_string('accounting/email/autopay_card_removed.html', context)),
        )
def _send_autopay_card_removed_email ( self , new_user , domain ) : from corehq . apps . domain . views . accounting import EditExistingBillingAccountView old_username = self . auto_pay_user subject = _ ( "Your card is no longer being used to auto-pay for {billing_account}" ) . format ( billing_account = self . name ) old_web_user = WebUser . get_by_username ( old_username ) old_user_first_name = old_web_user . first_name if old_web_user else old_username email = old_web_user . get_email ( ) if old_web_user else old_username context = { 'new_user' : new_user , 'old_user_name' : old_user_first_name , 'billing_account_name' : self . name , 'billing_info_url' : absolute_reverse ( EditExistingBillingAccountView . urlname , args = [ domain ] ) , 'invoicing_contact_email' : settings . INVOICING_CONTACT_EMAIL , } send_html_email_async ( subject , email , render_to_string ( 'accounting/email/autopay_card_removed.html' , context ) , text_content = strip_tags ( render_to_string ( 'accounting/email/autopay_card_removed.html' , context ) ) , )