def _gift_using_creddits(self, recipient, months=1, thing_fullname=None, proxying_for=None): with creddits_lock(c.user): if not c.user.employee and c.user.gold_creddits < months: err = RedditError("INSUFFICIENT_CREDDITS") self.on_validation_error(err) note = None buyer = c.user if c.user.name.lower() in g.live_config["proxy_gilding_accounts"]: note = "proxy-%s" % c.user.name if proxying_for: try: buyer = Account._by_name(proxying_for) except NotFound: pass send_gift( buyer=buyer, recipient=recipient, months=months, days=months * 31, signed=False, giftmessage=None, thing_fullname=thing_fullname, note=note, ) if not c.user.employee: c.user.gold_creddits -= months c.user._commit()
def update_gold_users(): now = datetime.now(g.display_tz) warning_days = 3 renew_msg = _("[Click here for details on how to set up an " "automatically-renewing subscription or to renew.]" "(/gold) If you have any thoughts, complaints, " "rants, suggestions about reddit gold, please write " "to us at %(gold_email)s. Your feedback would be " "much appreciated.\n\nThank you for your past " "patronage.") % { 'gold_email': g.goldsupport_email } for account in all_gold_users(): days_left = (account.gold_expiration - now).days if days_left < 0: if account.pref_creddit_autorenew: with creddits_lock(account): if account.gold_creddits > 0: admintools.adjust_gold_expiration(account, days=31) account.gold_creddits -= 1 account._commit() continue admintools.degolden(account) subject = _("Your reddit gold subscription has expired.") message = _("Your subscription to reddit gold has expired.") message += "\n\n" + renew_msg message = append_random_bottlecap_phrase(message) send_system_message(account, subject, message, distinguished='gold-auto') elif days_left <= warning_days and not account.gold_will_autorenew: hc_key = "gold_expiration_notice-" + account.name already_warned = g.hardcache.get(hc_key) if not already_warned: g.hardcache.set(hc_key, True, 86400 * (warning_days + 1)) subject = _("Your reddit gold subscription is about to " "expire!") message = _("Your subscription to reddit gold will be " "expiring soon.") message += "\n\n" + renew_msg message = append_random_bottlecap_phrase(message) send_system_message(account, subject, message, distinguished='gold-auto')
def update_gold_users(): now = datetime.now(g.display_tz) warning_days = 3 renew_msg = _("[Click here for details on how to set up an " "automatically-renewing subscription or to renew.]" "(/gold) If you have any thoughts, complaints, " "rants, suggestions about reddit gold, please write " "to us at %(gold_email)s. Your feedback would be " "much appreciated.\n\nThank you for your past " "patronage.") % {'gold_email': g.goldsupport_email} for account in all_gold_users(): days_left = (account.gold_expiration - now).days if days_left < 0: if account.pref_creddit_autorenew: with creddits_lock(account): if account.gold_creddits > 0: admintools.adjust_gold_expiration(account, days=31) account.gold_creddits -= 1 account._commit() continue admintools.degolden(account) subject = _("Your reddit gold subscription has expired.") message = _("Your subscription to reddit gold has expired.") message += "\n\n" + renew_msg message = append_random_bottlecap_phrase(message) send_system_message(account, subject, message, distinguished='gold-auto') elif days_left <= warning_days and not account.gold_will_autorenew: hc_key = "gold_expiration_notice-" + account.name already_warned = g.hardcache.get(hc_key) if not already_warned: g.hardcache.set(hc_key, True, 86400 * (warning_days + 1)) subject = _("Your reddit gold subscription is about to " "expire!") message = _("Your subscription to reddit gold will be " "expiring soon.") message += "\n\n" + renew_msg message = append_random_bottlecap_phrase(message) send_system_message(account, subject, message, distinguished='gold-auto')
def _gift_using_creddits(self, recipient, months=1, thing_fullname=None): with creddits_lock(c.user): if not c.user.employee and c.user.gold_creddits < months: err = RedditError("INSUFFICIENT_CREDDITS") self.on_validation_error(err) send_gift( buyer=c.user, recipient=recipient, months=months, days=months * 31, signed=False, giftmessage=None, thing_fullname=thing_fullname, ) if not c.user.employee: c.user.gold_creddits -= months c.user._commit()