From 29cf7ce612020febad653bfdbddb1799a8622212 Mon Sep 17 00:00:00 2001 From: shlurbee Date: Thu, 25 Oct 2012 12:52:33 -0700 Subject: [PATCH] Only show traffic settings for promo owner/admin Promos can have approved "viewers" but they shouldn't be able to edit traffic settings. This change hides the Settings tab unless the user is owner of the promo or an admin. --- r2/r2/lib/pages/trafficpages.py | 12 +++++++----- r2/r2/templates/promotraffichelp.html | 5 ----- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/r2/r2/lib/pages/trafficpages.py b/r2/r2/lib/pages/trafficpages.py index d26dd8987..f8a38ac2e 100644 --- a/r2/r2/lib/pages/trafficpages.py +++ b/r2/r2/lib/pages/trafficpages.py @@ -504,10 +504,13 @@ class PromoTraffic(Templated): def __init__(self, link): self.thing = link self.summary_tab = PromoLinkTrafficSummary(link) + # any traffic viewer can see summary, details, and help tabs but the + # settings tab is only visible to owners and admins tabs = [('summary', 'summary', self.summary_tab), - ('details', 'traffic by campaign', PromoCampaignTrafficTable(link)), - ('settings', 'settings', PromoTrafficSettings(link)), - ('help', 'help', PromoTrafficHelp())] + ('details', 'traffic by campaign', PromoCampaignTrafficTable(link))] + if c.user_is_sponsor or c.user._id == link.author_id: + tabs.append(('settings', 'settings', PromoTrafficSettings(link))) + tabs.append(('help', 'help', PromoTrafficHelp())) Templated.__init__(self, tabs=TabbedPane(tabs, True)) def as_csv(self): @@ -565,8 +568,7 @@ class PromoCampaignTrafficTable(Templated): class PromoTrafficSettings(Templated): def __init__(self, thing): self.thing = thing - editable = c.user_is_sponsor or c.user._id == thing.author_id - self.viewer_list = TrafficViewerList(thing, editable) + self.viewer_list = TrafficViewerList(thing, editable=True) self.traffic_url = promote.promotraffic_url(thing) Templated.__init__(self) diff --git a/r2/r2/templates/promotraffichelp.html b/r2/r2/templates/promotraffichelp.html index 58927a2a6..7d5d6c695 100644 --- a/r2/r2/templates/promotraffichelp.html +++ b/r2/r2/templates/promotraffichelp.html @@ -32,11 +32,6 @@ "three hours, and that daily totals will be preliminary until 24 " + "hours after the link has finished its run.")}

-

- ${_("You can share this traffic page with other reddit users. Add " + - "them to the viewers list in settings. They will be able to view " + - "stats but will not be able to edit the link.")} -

${_("Campaigns created before Sept 12, 2012 will not be included in " + "these totals.")}