mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-26 23:39:11 -05:00
Move moderator self-removal into the non-stylable edit moderators page.
This commit is contained in:
committed by
Neil Williams
parent
9c5936a7d9
commit
a70236f6fd
@@ -2436,6 +2436,9 @@ class UserList(Templated):
|
||||
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
|
||||
@@ -2718,6 +2721,10 @@ class ContributorList(UserList):
|
||||
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):
|
||||
@@ -2727,6 +2734,9 @@ class ModList(UserList):
|
||||
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
|
||||
|
||||
@@ -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; }
|
||||
@@ -4254,7 +4290,7 @@ dd { margin-left: 20px; }
|
||||
font-size: 130%;
|
||||
}
|
||||
|
||||
.titlebox form.toggle {
|
||||
.titlebox form.toggle, .leavemoderator {
|
||||
margin: 0;
|
||||
padding: 5px 0px;
|
||||
font-size: smaller;
|
||||
@@ -4262,7 +4298,8 @@ dd { margin-left: 20px; }
|
||||
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,
|
||||
@@ -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 */
|
||||
}
|
||||
|
||||
|
||||
@@ -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(" <", " <").replace("> ", "> "))
|
||||
%>
|
||||
<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">
|
||||
|
||||
@@ -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")}
|
||||
@@ -44,18 +39,25 @@
|
||||
${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:
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user