mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-28 16:28:01 -05:00
promotions: Separate admin view of /promoted/graph
Make the admin view of /promoted/analytics distinct from the non-admin view
This commit is contained in:
committed by
Neil Williams
parent
36191d3ac9
commit
96c0aef441
@@ -155,6 +155,7 @@ def make_map():
|
||||
controller='promote', action='pay')
|
||||
mc('/promoted/graph',
|
||||
controller='promote', action='graph')
|
||||
mc('/promoted/admin/graph', controller='promote', action='admingraph')
|
||||
mc('/promoted/inventory/:sr_name',
|
||||
controller='promote', action='inventory')
|
||||
mc('/promoted/traffic/headline/:link',
|
||||
|
||||
@@ -144,11 +144,15 @@ class PromoteController(ListingController):
|
||||
|
||||
@validate(VSponsor())
|
||||
def GET_graph(self):
|
||||
content = Promote_Graph()
|
||||
if c.user_is_sponsor and c.render_style == 'csv':
|
||||
return PromotePage("graph", content=Promote_Graph()).render()
|
||||
|
||||
@validate(VSponsorAdmin())
|
||||
def GET_admingraph(self):
|
||||
content = Promote_Graph(admin_view=True)
|
||||
if c.render_style == 'csv':
|
||||
c.response.content = content.as_csv()
|
||||
return c.response
|
||||
return PromotePage("graph", content = content).render()
|
||||
return PromotePage("admingraph", content=content).render()
|
||||
|
||||
|
||||
def GET_inventory(self, sr_name):
|
||||
|
||||
@@ -174,6 +174,7 @@ menu = MenuHandler(hot = _('hot'),
|
||||
future_promos = _('unseen'),
|
||||
roadblock = _('roadblock'),
|
||||
graph = _('analytics'),
|
||||
admin_graph = _('admin analytics'),
|
||||
live_promos = _('live'),
|
||||
unpaid_promos = _('unpaid'),
|
||||
pending_promos = _('pending'),
|
||||
|
||||
@@ -3050,6 +3050,10 @@ class PromotePage(Reddit):
|
||||
NamedButton('live_promos'),
|
||||
NamedButton('graph')]
|
||||
|
||||
if c.user_is_sponsor:
|
||||
buttons.append(NamedButton('admin_graph',
|
||||
dest='/admin/graph'))
|
||||
|
||||
menu = NavMenu(buttons, base_path = '/promoted',
|
||||
type='flatlist')
|
||||
|
||||
@@ -3506,7 +3510,8 @@ class Promote_Graph(Templated):
|
||||
|
||||
return promos
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self, admin_view=False):
|
||||
self.admin_view = admin_view and c.user_is_sponsor
|
||||
self.now = promote.promo_datetime_now()
|
||||
|
||||
start_date = promote.promo_datetime_now(offset = -7).date()
|
||||
@@ -3518,13 +3523,13 @@ class Promote_Graph(Templated):
|
||||
# these will be cached queries
|
||||
market, promo_counter = self.get_market(None, start_date, end_date)
|
||||
my_market = market
|
||||
if not c.user_is_sponsor:
|
||||
if not self.admin_view:
|
||||
my_market = self.get_market(c.user._id, start_date, end_date)[0]
|
||||
|
||||
# determine the range of each link
|
||||
promote_blocks = []
|
||||
def block_maker(link, bid_day, starti, endi, campaign):
|
||||
if ((c.user_is_sponsor or link.author_id == c.user._id)
|
||||
if ((self.admin_view or link.author_id == c.user._id)
|
||||
and not promote.is_rejected(link)
|
||||
and not promote.is_unpaid(link)):
|
||||
promote_blocks.append((link, starti, endi, campaign))
|
||||
|
||||
Reference in New Issue
Block a user