Skip to content

Commit

Permalink
Move moderator self-removal into the non-stylable edit moderators page.
Browse files Browse the repository at this point in the history
  • Loading branch information
chromakode authored and spladug committed Mar 6, 2012
1 parent 9c5936a commit a70236f
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 23 deletions.
10 changes: 10 additions & 0 deletions r2/r2/lib/pages/pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -2436,6 +2436,9 @@ def user_ids(self):
to be listing in this UserList instance"""
raise NotImplementedError

def can_remove_self(self):
return False

@property
def container_name(self):
return c.site._fullname
Expand Down Expand Up @@ -2718,6 +2721,10 @@ def user_ids(self):
class ModList(UserList):
"""Moderator list for a reddit."""
type = 'moderator'
remove_self_action = _('leave')
remove_self_title = _('you are a moderator of this subreddit. %(action)s')
remove_self_confirm = _('stop being a moderator?')
remove_self_final = _('you are no longer a moderator')

@property
def form_title(self):
Expand All @@ -2727,6 +2734,9 @@ def form_title(self):
def table_title(self):
return _("moderators of %(reddit)s") % dict(reddit = c.site.name)

def can_remove_self(self):
return c.user_is_loggedin and c.site.is_moderator(c.user)

def editable_fn(self, user):
if not c.user_is_loggedin:
return False
Expand Down
43 changes: 40 additions & 3 deletions r2/r2/public/static/css/reddit.css
Original file line number Diff line number Diff line change
Expand Up @@ -1859,6 +1859,42 @@ label + #moresearchinfo {
.usertable td, .usertable th { padding: 0 .7em }
.usertable { white-space: nowrap }

.usertable .remove-self {
display: inline-block;
margin: 1em 0 .5em;
padding: 11px 15px;
border: 1px solid #bbb;
border-radius: 2px;
}

.usertable .moderator.remove-self {
background: #fdffe8;
}

.usertable .remove-self .option.main:before {
margin-right: 7px;
}

.usertable .remove-self .option {
display: inline;
}

.usertable .remove-self .togglebutton, .usertable .remove-self .error {
display: none;
font-size: inherit;
border-left: 1px solid #bbb;
padding: 4px 15px;
padding-right: 0;
margin-left: 10px;
}

.usertable .remove-self .active .togglebutton {
display: inline;
}

.usertable .remove-self .error.active {
display: inline;
}

.aboutpage { margin-right: 320px; }
.aboutpage p { margin: 5px; }
Expand Down Expand Up @@ -4254,15 +4290,16 @@ dd { margin-left: 20px; }
font-size: 130%;
}

.titlebox form.toggle {
.titlebox form.toggle, .leavemoderator {
margin: 0;
padding: 5px 0px;
font-size: smaller;
color: gray;
background: white none no-repeat scroll center left;
}

.titlebox form.leavemoderator-button:before,
.usertable .remove-self .main:before,
.titlebox .leavemoderator:before,
.titlebox form.leavecontributor-button:before,
.icon-menu .reddit-edit:before,
.icon-menu .reddit-traffic:before,
Expand All @@ -4284,7 +4321,7 @@ dd { margin-left: 20px; }
margin-right: 5px;
}

.titlebox form.leavemoderator-button:before {
.titlebox .leavemoderator:before, .moderator.remove-self .main:before {
background-image: url(../shield.png); /* SPRITE */
}

Expand Down
9 changes: 5 additions & 4 deletions r2/r2/templates/printablebuttons.html
Original file line number Diff line number Diff line change
Expand Up @@ -377,21 +377,22 @@
question = None,
format = '%(link)s',
format_arg = 'link',
hidden_data = {})">
hidden_data = {},
_class = '')">
<%
if question is None:
question = _("are you sure?")
link = ('<a href="#" onclick="return toggle(this)">'
link = ('<a href="#" class="togglebutton" onclick="return toggle(this)">'
+ title + '</a>')
link = format % {format_arg : link}
link = unsafe(link.replace(" <", "&#32;<").replace("> ", ">&#32;"))
%>
<form class="toggle ${op}-button" action="#" method="get">
<form class="toggle ${op}-button ${_class}" action="#" method="get">
<input type="hidden" name="executed" value="${executed}"/>
%for k, v in hidden_data.iteritems():
<input type="hidden" name="${k}" value="${v}"/>
%endfor
<span class="option active">
<span class="option main active">
${link}
</span>
<span class="option error">
Expand Down
34 changes: 18 additions & 16 deletions r2/r2/templates/subredditinfobar.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,13 @@
<%!
import locale
from r2.lib.strings import strings, Score
from r2.lib.pages import WrappedUser
from r2.lib.pages import WrappedUser, ModList
%>

<%namespace file="utils.html" import="plain_link, thing_timestamp"/>
<%namespace file="utils.html" import="plain_link, thing_timestamp, text_with_links"/>
<%namespace file="subreddit.html" import="addremove_button" />
<%namespace file="printablebuttons.html" import="ynbutton, state_button" />

<%def name="moderate_button(location, fmt, question, left)">
${ynbutton(_("leave"), left, location,
question = question, format = fmt, format_arg = "leave",
hidden_data = dict(id = thing.sr._fullname))}
</%def>
<div class="titlebox">
<h1 class="hover redditname">
${plain_link(thing.sr.name, thing.sr.path, _sr_path=False, _class="hover")}
Expand All @@ -44,18 +39,25 @@ <h1 class="hover redditname">
${unsafe(Score.readers(thing.subscribers))}

%if thing.sr.moderator:
${moderate_button("leavemoderator",
_("you are a moderator of this reddit. (%(leave)s)"),
_("stop being a moderator?"),
_("you are no longer a moderator"))}

<div class="leavemoderator">
${text_with_links(ModList.remove_self_title % dict(action='(%(action)s)'),
_sr_path=True,
action=dict(
## TRANSLATORS: this label links to the edit moderators page.
link_text=_('change'),
path='about/moderators'))}
</div>
%endif

%if thing.sr.contributor:
${moderate_button("leavecontributor",
_("you are an approved submitter on this reddit. (%(leave)s)"),
_("stop being an approved submitter?"),
_("you are no longer an approved submitter"))}
${ynbutton(op='leavecontributor',
title=_('leave'),
executed=_('you are no longer an approved submitter'),
question=_('stop being an approved submitter?'),
format=_('you are an approved submitter on this reddit. (%(leave)s)'),
format_arg='leave',
hidden_data=dict(
id=thing.sr._fullname))}
%endif

%if thing.flair_prefs:
Expand Down
16 changes: 16 additions & 0 deletions r2/r2/templates/userlist.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,24 @@
################################################################################

<%namespace file="utils.html" import="error_field"/>
<%namespace file="printablebuttons.html" import="ynbutton" />
<% from r2.lib.template_helpers import static %>

<div class="${thing._class} usertable">
%if thing.can_remove_self():
${ynbutton(op=thing.remove_action,
title=thing.remove_self_action,
executed=thing.remove_self_final,
question=thing.remove_self_confirm,
format=thing.remove_self_title,
format_arg='action',
_class=thing.type + ' remove-self',
hidden_data=dict(
id=c.user._fullname,
type=thing.type,
container=thing.container_name))}
%endif

%if thing.addable:
<form action="/post/${thing.destination}"
method="post" class="pretty-form medium-text"
Expand Down

0 comments on commit a70236f

Please sign in to comment.