Skip to content

Commit

Permalink
Add mod tools box to /r/mod and multireddits.
Browse files Browse the repository at this point in the history
Additionally:
* Change the name "admin box" to "moderation tools".
* Move it to the top of the sidebar.
  • Loading branch information
spladug committed Apr 27, 2012
1 parent da6e4a2 commit 25466f7
Showing 1 changed file with 51 additions and 29 deletions.
80 changes: 51 additions & 29 deletions r2/r2/lib/pages/pages.py
Expand Up @@ -189,31 +189,48 @@ def __init__(self, space_compress = True, nav_menus = None, loginbox = True,
self.toolbars = self.build_toolbars()

def sr_admin_menu(self):
buttons = [NavButton(menu.community_settings, css_class = 'reddit-edit',
dest = "edit"),
NamedButton('modmail', dest = "message/inbox",
css_class = 'moderator-mail'),
NamedButton('moderators', css_class = 'reddit-moderators')]

if c.site.type != 'public':
buttons.append(NamedButton('contributors',
css_class = 'reddit-contributors'))
elif (c.user_is_loggedin and
(c.site.is_moderator(c.user) or c.user_is_admin)):
buttons.append(NavButton(menu.contributors, "contributors",
css_class = 'reddit-contributors'))

buttons.extend([
NamedButton('traffic', css_class = 'reddit-traffic'),
NamedButton('modqueue', css_class = 'reddit-modqueue'),
NamedButton('reports', css_class = 'reddit-reported'),
NamedButton('spam', css_class = 'reddit-spam'),
NamedButton('banned', css_class = 'reddit-ban'),
NamedButton('flair', css_class = 'reddit-flair'),
NamedButton('log', css_class = 'reddit-moderationlog'),
])
return [NavMenu(buttons, type = "flat_vert", base_path = "/about/",
css_class = "icon-menu", separator = '')]
buttons = []
is_single_subreddit = not isinstance(c.site, (ModSR, MultiReddit))

if is_single_subreddit:
buttons.append(NavButton(menu.community_settings,
css_class="reddit-edit",
dest="edit"))

buttons.append(NamedButton("modmail",
dest="message/inbox",
css_class="moderator-mail"))

if is_single_subreddit:
buttons.append(NamedButton("moderators",
css_class="reddit-moderators"))

if c.site.type != "public":
buttons.append(NamedButton("contributors",
css_class="reddit-contributors"))
else:
buttons.append(NavButton(menu.contributors,
"contributors",
css_class="reddit-contributors"))

buttons.append(NamedButton("traffic", css_class="reddit-traffic"))

buttons += [NamedButton("modqueue", css_class="reddit-modqueue"),
NamedButton("reports", css_class="reddit-reported"),
NamedButton("spam", css_class="reddit-spam")]

if is_single_subreddit:
buttons += [NamedButton("banned", css_class="reddit-ban"),
NamedButton("flair", css_class="reddit-flair")]

buttons.append(NamedButton("log", css_class="reddit-moderationlog"))

return SideContentBox(_('moderation tools'),
[NavMenu(buttons,
type="flat_vert",
base_path="/about/",
css_class="icon-menu",
separator="")])

def sr_moderators(self, limit = 10):
accounts = Account._byID([uid
Expand All @@ -235,10 +252,19 @@ def rightbox(self):
if c.user.pref_show_sponsorships or not c.user.gold:
ps.append(SponsorshipBox())

if (c.user_is_loggedin and (isinstance(c.site, ModSR) or
c.site.is_moderator(c.user))):
ps.append(self.sr_admin_menu())

no_ads_yet = True
if isinstance(c.site, (MultiReddit, ModSR)) and c.user_is_loggedin:
srs = Subreddit._byID(c.site.sr_ids,data=True,
return_dict=False)

if (isinstance(c.site, MultiReddit) and
Subreddit.user_mods_all(c.user, srs)):
ps.append(self.sr_admin_menu())

if srs:
ps.append(SideContentBox(_('these reddits'),[SubscriptionBox(srs=srs)]))

Expand Down Expand Up @@ -291,10 +317,6 @@ def rightbox(self):
more_href = mod_href,
more_text = more_text))

if (c.user_is_loggedin and
(c.site.is_moderator(c.user) or c.user_is_admin)):
ps.append(SideContentBox(_('admin box'), self.sr_admin_menu()))


if no_ads_yet and not g.disable_ads:
if c.user.pref_show_adbox or not c.user.gold:
Expand Down

0 comments on commit 25466f7

Please sign in to comment.