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.
This commit is contained in:
shlurbee
2012-10-25 12:52:33 -07:00
parent f9b091804a
commit 29cf7ce612
2 changed files with 7 additions and 10 deletions

View File

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

View File

@@ -32,11 +32,6 @@
"three hours, and that daily totals will be preliminary until 24 " +
"hours after the link has finished its run.")}
</p>
<p>
${_("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.")}
</p>
<p>
${_("Campaigns created before Sept 12, 2012 will not be included in " +
"these totals.")}