diff --git a/r2/r2/lib/pages/pages.py b/r2/r2/lib/pages/pages.py index fe9c0d47b..3575972f7 100644 --- a/r2/r2/lib/pages/pages.py +++ b/r2/r2/lib/pages/pages.py @@ -23,10 +23,10 @@ from collections import Counter, OrderedDict from r2.lib.wrapped import Wrapped, Templated, CachedTemplate -from r2.models import Account, FakeAccount, DefaultSR, make_feedurl +from r2.models import Account, DefaultSR, make_feedurl from r2.models import FakeSubreddit, Subreddit, SubSR, AllMinus, AllSR from r2.models import Friends, All, Sub, NotFound, DomainSR, Random, Mod, RandomNSFW, RandomSubscription, MultiReddit, ModSR, Frontpage, LabeledMulti -from r2.models import Link, Printable, Trophy, PromoCampaign, PromotionWeights, Comment +from r2.models import Link, Printable, Trophy, PromoCampaign, Comment from r2.models import Flair, FlairTemplate, FlairTemplateBySubredditIndex from r2.models import USER_FLAIR, LINK_FLAIR from r2.models.bidding import Bid @@ -3801,63 +3801,6 @@ class PaymentForm(Templated): locale=c.locale) Templated.__init__(self, **kw) -class Promotion_Summary(Templated): - def __init__(self, ndays): - end_date = promote.promo_datetime_now().date() - start_date = promote.promo_datetime_now(offset = -ndays).date() - - pws = PromotionWeights.get_campaigns(start_date, - end_date + datetime.timedelta(1)) - campaign_ids = {pw.promo_idx for pw in pws} - campaigns = PromoCampaign._byID(campaign_ids, data=True, - return_dict=False) - link_ids = {camp.link_id for camp in campaigns} - link_names = {Link._fullname_from_id36(to36(id)) for id in link_ids} - wrapped_links = wrap_links(link_names) - wrapped_links_by_id = {link._id: link for link in wrapped_links} - account_ids = {camp.owner_id for camp in campaigns} - accounts_by_id = Account._byID(account_ids, data=True) - - links = set() - total = 0 - for campaign in campaigns: - if not campaign.trans_id or campaign.trans_id <= 0: - continue - - link = wrapped_links_by_id[campaign.link_id] - if not promote.is_accepted(link): - continue - - link.bid = getattr(link, "bid", 0) - link.bid += (campaign.bid - getattr(campaign, 'refund_amount', 0)) - link.ncampaigns = getattr(link, "ncampaigns", 0) + 1 - links.add(link) - - # calculate portion of this campaign's budget to include, assuming - # even delivery - bid_per_day = campaign.bid / campaign.ndays - sd = max(start_date, campaign.start_date.date()) - ed = min(end_date, campaign.end_date.date()) - total += bid_per_day * (ed - sd).days - - links = list(links) - links.sort(key = lambda x: x._score, reverse = True) - - self.links = links - self.ndays = ndays - self.total = total - Templated.__init__(self) - - @classmethod - def send_summary_email(cls, to_addr, ndays): - from r2.lib import emailer - c.site = DefaultSR() - c.user = FakeAccount() - p = cls(ndays) - emailer.send_html_email(to_addr, g.feedback_email, - "Self-serve promotion summary for last %d days" - % ndays, p.render('email')) - class PromoteInventory(Templated): def __init__(self, start, end, sr): diff --git a/r2/r2/templates/promotion_summary.email b/r2/r2/templates/promotion_summary.email deleted file mode 100644 index 1ae989a0d..000000000 --- a/r2/r2/templates/promotion_summary.email +++ /dev/null @@ -1,62 +0,0 @@ -## The contents of this file are subject to the Common Public Attribution -## License Version 1.0. (the "License"); you may not use this file except in -## compliance with the License. You may obtain a copy of the License at -## http://code.reddit.com/LICENSE. The License is based on the Mozilla Public -## License Version 1.1, but Sections 14 and 15 have been added to cover use of -## software over a computer network and provide for limited attribution for the -## Original Developer. In addition, Exhibit A has been modified to be -## consistent with Exhibit B. -## -## Software distributed under the License is distributed on an "AS IS" basis, -## WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for -## the specific language governing rights and limitations under the License. -## -## The Original Code is reddit. -## -## The Original Developer is the Initial Developer. The Initial Developer of -## the Original Code is reddit Inc. -## -## All portions of the code written by reddit are Copyright (c) 2006-2013 -## reddit Inc. All Rights Reserved. -############################################################################### - -<% import locale %> - -
- - -- Averaging $${"%.2f" % (thing.total / thing.ndays)} via authorize.net per day for the last ${thing.ndays} days. -
- -- Yearly projection: - $${locale.format("%d", int(365 * thing.total / thing.ndays), True)} -
- -Top 20 sponsored links this week:
- -