Skip to content
Browse files

Add mod tools box to /r/mod and multireddits.

Additionally:
* Change the name "admin box" to "moderation tools".
* Move it to the top of the sidebar.
  • Loading branch information...
1 parent da6e4a2 commit 25466f7cf0f1d99a23cb73e48c63b44224c3089b @spladug spladug committed Apr 26, 2012
Showing with 51 additions and 29 deletions.
  1. +51 −29 r2/r2/lib/pages/pages.py
View
80 r2/r2/lib/pages/pages.py
@@ -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
@@ -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)]))
@@ -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:

0 comments on commit 25466f7

Please sign in to comment.
Something went wrong with that request. Please try again.