From a70236f6fd9c04ec955f65ab93cdc7abb5829b8e Mon Sep 17 00:00:00 2001 From: Max Goodman Date: Sat, 3 Mar 2012 21:43:49 -0800 Subject: [PATCH] Move moderator self-removal into the non-stylable edit moderators page. --- r2/r2/lib/pages/pages.py | 10 +++++++ r2/r2/public/static/css/reddit.css | 43 +++++++++++++++++++++++++-- r2/r2/templates/printablebuttons.html | 9 +++--- r2/r2/templates/subredditinfobar.html | 34 +++++++++++---------- r2/r2/templates/userlist.html | 16 ++++++++++ 5 files changed, 89 insertions(+), 23 deletions(-) diff --git a/r2/r2/lib/pages/pages.py b/r2/r2/lib/pages/pages.py index 303c64f5f..897c5cc52 100644 --- a/r2/r2/lib/pages/pages.py +++ b/r2/r2/lib/pages/pages.py @@ -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 diff --git a/r2/r2/public/static/css/reddit.css b/r2/r2/public/static/css/reddit.css index c98c4e240..dc06e0d22 100644 --- a/r2/r2/public/static/css/reddit.css +++ b/r2/r2/public/static/css/reddit.css @@ -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 */ } diff --git a/r2/r2/templates/printablebuttons.html b/r2/r2/templates/printablebuttons.html index 927b739b8..74ef5e2db 100644 --- a/r2/r2/templates/printablebuttons.html +++ b/r2/r2/templates/printablebuttons.html @@ -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 = ('' + link = ('' + title + '') link = format % {format_arg : link} link = unsafe(link.replace(" <", " <").replace("> ", "> ")) %> -
+ %for k, v in hidden_data.iteritems(): %endfor - + ${link} diff --git a/r2/r2/templates/subredditinfobar.html b/r2/r2/templates/subredditinfobar.html index 1b0eada1e..13a865dba 100644 --- a/r2/r2/templates/subredditinfobar.html +++ b/r2/r2/templates/subredditinfobar.html @@ -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))} -

${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"))} - +
+ ${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'))} +
%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: diff --git a/r2/r2/templates/userlist.html b/r2/r2/templates/userlist.html index b3e83005d..d69adf934 100644 --- a/r2/r2/templates/userlist.html +++ b/r2/r2/templates/userlist.html @@ -21,8 +21,24 @@ ################################################################################ <%namespace file="utils.html" import="error_field"/> +<%namespace file="printablebuttons.html" import="ynbutton" /> <% from r2.lib.template_helpers import static %> +
+ %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: