def email_user(self, user, cash_position, low_margin, high_margin, severe): """ :param user: :type user: User :param cash_position: :type cash_position: int :param low_margin: :type low_margin: int :param high_margin: :type high_margin: int :param severe: :type severe: bool """ template_file = "margin_call.{locale}.email" if severe else "low_margin.{locale}.email" t = util.get_locale_template(user.locale, self.jinja_env, template_file) content = t.render( cash_position=util.quantity_fmt(self.BTC, cash_position), low_margin=util.quantity_fmt(self.BTC, low_margin), high_margin=util.quantity_fmt(self.BTC, high_margin), user=user).encode('utf-8') # Now send the mail log.msg("Sending mail: %s" % content) self.sendmail.send_mail( content, to_address=user.email, subject="Margin Call" if severe else "Margin Warning")
def notify_pending_withdrawal(self, withdrawal): """ email notification of withdrawal pending to the user. """ # Now email the notification t = util.get_locale_template(withdrawal.user.locale, self.jinja_env, 'pending_withdrawal.{locale}.email') content = t.render(withdrawal=withdrawal).encode('utf-8') # Now email the token log.msg("Sending mail: %s" % content) s = self.sendmail.send_mail(content, to_address='<%s> %s' % (withdrawal.user.email, withdrawal.user.nickname), subject='Your withdrawal request is pending')
def notify_pending_withdrawal(self, withdrawal): """ email notification of withdrawal pending to the user. """ # Now email the notification t = util.get_locale_template(withdrawal.user.locale, self.jinja_env, 'pending_withdrawal.{locale}.email') content = t.render(withdrawal=withdrawal).encode('utf-8') # Now email the token log.msg("Sending mail: %s" % content) s = self.sendmail.send_mail( content, to_address='<%s> %s' % (withdrawal.user.email, withdrawal.user.nickname), subject='Your withdrawal request is pending')
def email_user(self, user, cash_position, low_margin, high_margin, severe): """ :param user: :type user: User :param cash_position: :type cash_position: int :param low_margin: :type low_margin: int :param high_margin: :type high_margin: int :param severe: :type severe: bool """ template_file = "margin_call.{locale}.email" if severe else "low_margin.{locale}.email" t = util.get_locale_template(user.locale, self.jinja_env, template_file) content = t.render(cash_position=util.quantity_fmt(self.BTC, cash_position), low_margin=util.quantity_fmt(self.BTC, low_margin), high_margin=util.quantity_fmt(self.BTC, high_margin), user=user).encode('utf-8') # Now send the mail log.msg("Sending mail: %s" % content) self.sendmail.send_mail(content, to_address=user.email, subject="Margin Call" if severe else "Margin Warning")