Delete selfserve summary emails.

This commit is contained in:
Brian Simpson
2014-03-15 19:30:40 -04:00
parent 906678a149
commit bd75868584
2 changed files with 2 additions and 121 deletions

View File

@@ -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):

View File

@@ -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 %>
<html>
<head>
</head>
<body>
<div style="font: normal x-small verdana, arial, helvetica, sans-serif;">
<p style="font-size:larger">
Averaging <b>$${"%.2f" % (thing.total / thing.ndays)}</b> via authorize.net per day for the last ${thing.ndays} days.
</p>
<p style="font-size:larger">
Yearly projection: <span style="color:#00B800; font-weight:bold">
$${locale.format("%d", int(365 * thing.total / thing.ndays), True)}</span>
</p>
<p style="font-size:larger">Top 20 sponsored links this week:</p>
<ol><% counter = 0 %>
%for l in thing.links:
%if not getattr(l.author, "ignore_promos_report", False) and not getattr(l.author, "complimentary_promos", False) and counter < 20:
<% counter +=1 %>
<li style="padding-bottom: 3px">
<a class="title" href="${l.url}" rel="nofollow"
style="text-decoration:none; font-size:larger">${l.title}</a><br/>
<span style="color:gray; cont-size:smaller;">
${l.score} points submitted
by&#32;<a href="http://www.reddit.com/user/${l.author.name}"
style="text-decoration:none">${l.author.name}</a>
</span><br/>
<span style="cont-size:smaller;">
<a class="permalink" href="http://www.reddit.com${l.permalink}">permalink</a>&#32;(<b>${l.ncampaigns}</b> campaign(s) for <b>$${l.bid}</b>)
</span>
</li>
%endif
%endfor
</ol>
</div>
</body>
</html>