def bounty_expire_warning(bounty, to_emails=None): if not bounty or not bounty.value_in_usdt_now: return if to_emails is None: to_emails = [] for to_email in to_emails: cur_language = translation.get_language() try: setup_lang(to_email) unit = _('day') num = int(round((bounty.expires_date - timezone.now()).days, 0)) if num == 0: unit = _('hour') num = int(round((bounty.expires_date - timezone.now()).seconds / 3600 / 24, 0)) unit = unit + ("s" if num != 1 else "") subject = gettext("😕 Your Funded Issue ({}) Expires In {} {} ... 😕").format(bounty.title_or_desc, num, unit) from_email = settings.CONTACT_EMAIL html, text = render_bounty_expire_warning(to_email, bounty) if not should_suppress_notification_email(to_email, 'bounty_expiration'): send_mail(from_email, to_email, subject, text, html, categories=['transactional', func_name()]) finally: translation.activate(cur_language)
def bounty_expire_warning(bounty, to_emails=None): if not bounty or not bounty.value_in_usdt: return if to_emails is None: to_emails = [] for to_email in to_emails: unit = 'day' num = int(round((bounty.expires_date - timezone.now()).days, 0)) if num == 0: unit = 'hour' num = int( round( (bounty.expires_date - timezone.now()).seconds / 3600 / 24, 0)) unit = unit + ("s" if num != 1 else "") subject = "😕 Your Funded Issue ({}) Expires In {} {} ... 😕".format( bounty.title_or_desc, num, unit) from_email = settings.CONTACT_EMAIL html, text = render_bounty_expire_warning(to_email, bounty) if not should_suppress_notification_email(to_email): send_mail(from_email, to_email, subject, text, html)