mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-26 15:28:37 -05:00
Revert "Promo admin tool"
This reverts commit 301512551aca1231f7bc3cbd7bca96720415ef35.
This commit is contained in:
@@ -198,7 +198,6 @@ def make_map():
|
||||
mc('/framebuster/:what/:blah',
|
||||
controller='front', action='framebuster')
|
||||
|
||||
mc('/admin/promoted', controller='promote', action='admin')
|
||||
mc('/promoted/edit_promo/:link',
|
||||
controller='promote', action='edit_promo')
|
||||
mc('/promoted/edit_promo_cpm/:link', # development only
|
||||
|
||||
@@ -40,7 +40,6 @@ from r2.lib.menus import NamedButton, NavButton, NavMenu
|
||||
from r2.lib.pages import (
|
||||
LinkInfoPage,
|
||||
PaymentForm,
|
||||
PromoAdminTool,
|
||||
Promote_Graph,
|
||||
PromotePage,
|
||||
PromoteLinkForm,
|
||||
@@ -838,16 +837,6 @@ class PromoteController(ListingController):
|
||||
errors=errors,
|
||||
form_id="image-upload").render()
|
||||
|
||||
@validate(VSponsorAdmin(),
|
||||
launchdate=VDate('ondate'),
|
||||
dates=VDateRange(['startdate', 'enddate']),
|
||||
query_type=VOneOf('q', ('started_on', 'between'), default=None))
|
||||
def GET_admin(self, launchdate=None, dates=None, query_type=None):
|
||||
return PromoAdminTool(query_type=query_type,
|
||||
launchdate=launchdate,
|
||||
start=dates[0],
|
||||
end=dates[1]).render()
|
||||
|
||||
@validate(VSponsorAdminOrAdminSecret('secret'),
|
||||
start=VDate('startdate'),
|
||||
end=VDate('enddate'),
|
||||
|
||||
@@ -3539,62 +3539,6 @@ class PromoteLinkForm(Templated):
|
||||
message %= {'link': 'http://www.slideshare.net/reddit/how-to-use-reddits-selfserve-advertising-platform'}
|
||||
self.infobar = InfoBar(message=message)
|
||||
|
||||
class PromoAdminTool(Reddit):
|
||||
def __init__(self, query_type=None, launchdate=None, start=None, end=None, *a, **kw):
|
||||
self.query_type = query_type
|
||||
self.launch = launchdate if launchdate else datetime.datetime.now()
|
||||
self.start = start if start else datetime.datetime.now()
|
||||
self.end = end if end else self.start + datetime.timedelta(1)
|
||||
# started_on shows promos that were scheduled to launch on start date
|
||||
if query_type == "started_on" and self.start:
|
||||
all_promos = self.get_promo_info(self.start,
|
||||
self.start + datetime.timedelta(1)) # exactly one day
|
||||
promos = {}
|
||||
start_date_string = self.start.strftime("%Y/%m/%d")
|
||||
for camp_id, data in all_promos.iteritems():
|
||||
if start_date_string == data["campaign_start"]:
|
||||
promos[camp_id] = data
|
||||
# between shows any promo that was scheduled on at least one day in
|
||||
# the range [start, end)
|
||||
elif query_type == "between" and self.start and self.end:
|
||||
promos = self.get_promo_info(self.start, self.end)
|
||||
else:
|
||||
promos = {}
|
||||
|
||||
for camp_id, promo in promos.iteritems():
|
||||
link_id36 = promo["link_fullname"].split('_')[1]
|
||||
promo["campaign_id"] = camp_id
|
||||
promo["edit_link"] = promote.promo_edit_url(None, id36=link_id36)
|
||||
|
||||
self.promos = sorted(promos.values(),
|
||||
key=lambda x: (x['username'], x['campaign_start']))
|
||||
|
||||
Reddit.__init__(self, title="Promo Admin Tool", show_sidebar=False)
|
||||
|
||||
|
||||
def get_promo_info(self, start_date, end_date):
|
||||
promo_info = {}
|
||||
scheduled = Promote_Graph.get_current_promos(start_date,
|
||||
end_date + datetime.timedelta(1))
|
||||
campaign_ids = [x[1] for x in scheduled]
|
||||
campaigns = PromoCampaign._byID(campaign_ids, data=True, return_dict=True)
|
||||
account_ids = [pc.owner_id for pc in campaigns.itervalues()]
|
||||
accounts = Account._byID(account_ids, data=True, return_dict=True)
|
||||
for link, campaign_id, scheduled_start, scheduled_end in scheduled:
|
||||
campaign = campaigns[campaign_id]
|
||||
bid_per_day = float(campaign.bid) / campaign.ndays
|
||||
account = accounts[campaign.owner_id]
|
||||
promo_info[campaign._id] = {
|
||||
'username': account.name,
|
||||
'user_email': account.email,
|
||||
'link_title': link.title,
|
||||
'link_fullname': link._fullname,
|
||||
'campaign_start': campaign.start_date.strftime("%Y/%m/%d"),
|
||||
'campaign_end': campaign.end_date.strftime("%Y/%m/%d"),
|
||||
'bid_per_day': bid_per_day,
|
||||
}
|
||||
return promo_info
|
||||
|
||||
|
||||
class RefundPage(Reddit):
|
||||
def __init__(self, link, campaign):
|
||||
|
||||
@@ -117,10 +117,9 @@ def promotraffic_url(l): # new traffic url
|
||||
domain = get_domain(cname=False, subreddit=False)
|
||||
return "http://%s/promoted/traffic/headline/%s" % (domain, l._id36)
|
||||
|
||||
def promo_edit_url(l=None, id36=""):
|
||||
if l: id36 = l._id36
|
||||
def promo_edit_url(l):
|
||||
domain = get_domain(cname=False, subreddit=False)
|
||||
return "http://%s/promoted/edit_promo/%s" % (domain, id36)
|
||||
return "http://%s/promoted/edit_promo/%s" % (domain, l._id36)
|
||||
|
||||
def pay_url(l, campaign):
|
||||
return "%spromoted/pay/%s/%s" % (g.payment_domain, l._id36, campaign._id36)
|
||||
|
||||
@@ -4762,23 +4762,6 @@ div.timeseries span.title {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.promo-admin-form {
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.promo-admin-form button {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.promo-admin-data th {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.promo-admin-data td, .promo-admin-data th {
|
||||
padding: 1px 4px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
p.totals-are-preliminary {
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
@@ -1,43 +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.
|
||||
###############################################################################
|
||||
|
||||
<%inherit file="reddit.html"/>
|
||||
|
||||
<%def name="stylesheet()">
|
||||
${parent.stylesheet()}
|
||||
<style>
|
||||
.promo-admin-form {
|
||||
padding: 10px;
|
||||
}
|
||||
.promo-admin-form button {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.promo-data th {
|
||||
font-weight: bold;
|
||||
}
|
||||
.promo-data td, .promo-data th {
|
||||
padding: 1px 4px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
</style>
|
||||
</%def>
|
||||
|
||||
@@ -1,109 +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.
|
||||
###############################################################################
|
||||
|
||||
<%inherit file="reddit.html"/>
|
||||
|
||||
<%!
|
||||
from r2.lib.template_helpers import static
|
||||
from r2.lib import js
|
||||
%>
|
||||
|
||||
<%namespace name="pr" file="promotelinkform.html" />
|
||||
<%namespace name="utils" file="utils.html"/>
|
||||
|
||||
<%def name="javascript()">
|
||||
${parent.javascript()}
|
||||
${unsafe(js.use('sponsored'))}
|
||||
</%def>
|
||||
|
||||
<%def name="bodyHTML()">
|
||||
<form id="promotion-history" method="get" action="/admin/promoted">
|
||||
<div class="promo-admin-form">
|
||||
<div class="promo-admin-row" onclick="$('#qstarted_on').attr('checked', true);">
|
||||
<input type="hidden" id="date-min" name="date-min" value="6/30/2012" />
|
||||
<input type="radio" name="q" id="qstarted_on" value="started_on" checked=1>
|
||||
see ads that started on:
|
||||
</input>
|
||||
<%pr:datepicker name="ondate" value="${thing.start.strftime('%m/%d/%Y')}"
|
||||
minDateSrc="date-min" initfuncname="init_ondate" min_date_offset="86400000">
|
||||
function(elem) { return elem; }
|
||||
</%pr:datepicker>
|
||||
</div>
|
||||
<div class="promo-admin-row" onclick="$('#qbetween').attr('checked', true);">
|
||||
<input type="radio" name="q" id="qbetween" value="between" ${"checked=1" if thing.query_type=="between" else ""}>
|
||||
see ads that were running any day between:
|
||||
</input>
|
||||
<%pr:datepicker name="startdate" value="${thing.launch.strftime('%m/%d/%Y')}"
|
||||
minDateSrc="date-min" initfuncname="init_startdate" min_date_offset="86400000">
|
||||
function(elem) { return elem; }
|
||||
</%pr:datepicker>
|
||||
and
|
||||
<%pr:datepicker name="enddate" value="${thing.end.strftime('%m/%d/%Y')}"
|
||||
minDateSrc="date-min" initfuncname="init_enddate" min_date_offset="86400000">
|
||||
function(elem) { return elem; }
|
||||
</%pr:datepicker>
|
||||
(inclusive)
|
||||
</div>
|
||||
<div>
|
||||
<button class="fancybutton">show</button>
|
||||
</div>
|
||||
<div>
|
||||
</form>
|
||||
|
||||
## init date pickers
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
init_ondate();
|
||||
init_startdate();
|
||||
init_enddate();
|
||||
})
|
||||
</script>
|
||||
|
||||
<div>
|
||||
<table class='promo-admin-data'>
|
||||
<tr>
|
||||
<th>campaign</th>
|
||||
<th>username</th>
|
||||
<th>user email</th>
|
||||
<th>campaign start</th>
|
||||
<th>campaign end</th>
|
||||
<th>bid per day</th>
|
||||
<th>edit link</th>
|
||||
<th>link title</th>
|
||||
</tr>
|
||||
|
||||
%for p in thing.promos:
|
||||
<tr>
|
||||
<td>${p['campaign_id']}</td>
|
||||
<td>${p['username']}</td>
|
||||
<td><a href="mailto:${p['user_email']}" target="_blank">${p['user_email']}</a></td>
|
||||
<td>${p['campaign_start']}</td>
|
||||
<td>${p['campaign_end']}</td>
|
||||
<td class="right">$${"%0.2f" % p['bid_per_day']}</td>
|
||||
<td><a href="${p['edit_link']}" target="_blank">${p['edit_link']}</a></td>
|
||||
<td>${p['link_title']}</td>
|
||||
</tr>
|
||||
%endfor
|
||||
|
||||
</table>
|
||||
</div>
|
||||
</%def>
|
||||
Reference in New Issue
Block a user