Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: reddit/reddit
base: 8aadbc34c90e77af5e3bef16bf99f495e5f6ed0e
...
head fork: reddit/reddit
compare: 09c572c964d9eb2d7089231af4097c7ce7081cad
  • 3 commits
  • 12 files changed
  • 0 commit comments
  • 2 contributors
Commits on Feb 14, 2013
@alienth alienth Add ignore/unignore reports functionality for moderators.
When a thing has ignore_reports, the thing is no longer added to the moderator
cached queries (reported queue, mod queue, etc) when a user reports it.
8e212ca
@alienth alienth Adjust how and when builder shows reports and big_modbuttons.
Always show big_modbuttons on spamlistings (report listing, mod listing, etc).

Only display reports if ignore_reports is False or the user is admin.
02bd09a
Max Goodman Make ignore reports button a 2-state toggle button. 09c572c
View
34 r2/r2/controllers/api.py
@@ -1062,6 +1062,8 @@ def POST_editusertext(self, form, jquery, item, text):
or (item._ups + item._downs > 2)):
item.editted = c.start_time
+ item.ignore_reports = False
+
item._commit()
changed(item)
@@ -1856,6 +1858,38 @@ def POST_approve(self, thing):
ModAction.create(sr, c.user, action, **kw)
@require_oauth2_scope("modposts")
+ @noresponse(VUser(), VModhash(),
+ VSrCanBan('id'),
+ thing=VByName('id'))
+ @api_doc(api_section.moderation)
+ def POST_ignore_reports(self, thing):
+ if not thing: return
+ if thing._deleted: return
+ if thing.ignore_reports: return
+
+ thing.ignore_reports = True
+ thing._commit()
+
+ sr = thing.subreddit_slow
+ ModAction.create(sr, c.user, 'ignorereports', target=thing)
+
+ @require_oauth2_scope("modposts")
+ @noresponse(VUser(), VModhash(),
+ VSrCanBan('id'),
+ thing=VByName('id'))
+ @api_doc(api_section.moderation)
+ def POST_unignore_reports(self, thing):
+ if not thing: return
+ if thing._deleted: return
+ if not thing.ignore_reports: return
+
+ thing.ignore_reports = False
+ thing._commit()
+
+ sr = thing.subreddit_slow
+ ModAction.create(sr, c.user, 'unignorereports', target=thing)
+
+ @require_oauth2_scope("modposts")
@validatedForm(VUser(), VModhash(),
VCanDistinguish(('id', 'how')),
thing = VByName('id'),
View
4 r2/r2/controllers/front.py
@@ -548,7 +548,9 @@ def keep_fn(x):
num = num, after = after,
keep_fn = keep_fn,
count = count, reverse = reverse,
- wrap = ListingController.builder_wrapper)
+ wrap = ListingController.builder_wrapper,
+ spam_listing = True,
+ )
listing = LinkListing(builder)
pane = listing.listing()
View
2  r2/r2/lib/pages/things.py
@@ -122,6 +122,7 @@ def __init__(self, thing, comments = True, delete = True, report = True):
saved = thing.saved,
editable = thing.editable,
hidden = thing.hidden,
+ ignore_reports = thing.ignore_reports,
show_delete = show_delete,
show_report = show_report and c.user_is_loggedin,
show_distinguish = show_distinguish,
@@ -167,6 +168,7 @@ def __init__(self, thing, delete = True, report = True):
profilepage = c.profilepage,
permalink = thing.permalink,
saved = thing.saved,
+ ignore_reports = thing.ignore_reports,
new_window = c.user.pref_newwindow,
full_comment_path = thing.full_comment_path,
deleted = thing.deleted,
View
13 r2/r2/models/builder.py
@@ -49,10 +49,11 @@
MAX_RECURSION = 10
class Builder(object):
- def __init__(self, wrap=Wrapped, keep_fn=None, stale=True):
+ def __init__(self, wrap=Wrapped, keep_fn=None, stale=True, spam_listing=False):
self.stale = stale
self.wrap = wrap
self.keep_fn = keep_fn
+ self.spam_listing = spam_listing
def keep_item(self, item):
if self.keep_fn:
@@ -221,7 +222,7 @@ def wrap_items(self, items):
w.show_reports = False
w.show_spam = False
w.can_ban = False
- w.use_big_modbuttons = False
+ w.use_big_modbuttons = self.spam_listing
if (c.user_is_admin
or (user
@@ -249,7 +250,8 @@ def wrap_items(self, items):
w._spam = False
w.use_big_modbuttons = False
- elif getattr(item, 'reported', 0) > 0:
+ elif (getattr(item, 'reported', 0) > 0
+ and (not getattr(item, 'ignore_reports', False) or c.user_is_admin)):
w.show_reports = True
w.use_big_modbuttons = True
@@ -280,8 +282,9 @@ def must_skip(self, item):
return True
class QueryBuilder(Builder):
- def __init__(self, query, wrap=Wrapped, keep_fn=None, skip=False, **kw):
- Builder.__init__(self, wrap=wrap, keep_fn=keep_fn)
+ def __init__(self, query, wrap=Wrapped, keep_fn=None, skip=False,
+ spam_listing=False, **kw):
+ Builder.__init__(self, wrap=wrap, keep_fn=keep_fn, spam_listing=spam_listing)
self.query = query
self.skip = skip
self.num = kw.get('num')
View
6 r2/r2/models/link.py
@@ -75,6 +75,7 @@ class Link(Thing, Printable):
comment_tree_id=0,
contest_mode=False,
skip_commentstree_q="",
+ ignore_reports=False,
)
_essentials = ('sr_id', 'author_id')
_nsfw = re.compile(r"\bnsfw\b", re.I)
@@ -285,6 +286,7 @@ def wrapped_cache_key(wrapped, style):
s.append(getattr(wrapped, 'media_object', {}))
s.append(wrapped.flair_text)
s.append(wrapped.flair_css_class)
+ s.append(wrapped.ignore_reports)
# if browsing a single subreddit, incorporate link flair position
# in the key so 'flair' buttons show up appropriately for mods
@@ -689,7 +691,9 @@ class Comment(Thing, Printable):
new=False,
gildings=0,
banned_before_moderator=False,
- parents=None)
+ parents=None,
+ ignore_reports=False,
+ )
_essentials = ('link_id', 'author_id')
def _markdown(self):
View
14 r2/r2/models/modaction.py
@@ -55,7 +55,8 @@ class ModAction(tdb_cassandra.UuidThing, Printable):
'removemoderator', 'addcontributor', 'removecontributor',
'editsettings', 'editflair', 'distinguish', 'marknsfw',
'wikibanned', 'wikicontributor', 'wikiunbanned',
- 'removewikicontributor', 'wikirevise', 'wikipermlevel')
+ 'removewikicontributor', 'wikirevise', 'wikipermlevel',
+ 'ignorereports', 'unignorereports')
_menu = {'banuser': _('ban user'),
'unbanuser': _('unban user'),
@@ -79,7 +80,9 @@ class ModAction(tdb_cassandra.UuidThing, Printable):
'wikicontributor': _('add wiki contributor'),
'removewikicontributor': _('remove wiki contributor'),
'wikirevise': _('wiki revise page'),
- 'wikipermlevel': _('wiki page permissions')}
+ 'wikipermlevel': _('wiki page permissions'),
+ 'ignorereports': _('ignore reports'),
+ 'unignorereports': _('unignore reports')}
_text = {'banuser': _('banned'),
'wikibanned': _('wiki banned'),
@@ -103,7 +106,9 @@ class ModAction(tdb_cassandra.UuidThing, Printable):
'wikirevise': _('edited wiki page'),
'wikipermlevel': _('changed wiki page permission level'),
'distinguish': _('distinguished'),
- 'marknsfw': _('marked nsfw')}
+ 'marknsfw': _('marked nsfw'),
+ 'ignorereports': _('ignored reports'),
+ 'unignorereports': _('unignored reports')}
_details_text = {# approve comment/link
'unspam': _('unspam'),
@@ -146,7 +151,8 @@ class ModAction(tdb_cassandra.UuidThing, Printable):
'flair_delete_template': _('delete flair template'),
'flair_clear_template': _('clear flair templates'),
# distinguish/nsfw
- 'remove': _('remove')}
+ 'remove': _('remove'),
+ 'ignore_reports': _('ignore reports')}
# This stuff won't change
cache_ignore = set(['subreddit', 'target']).union(Printable.cache_ignore)
View
4 r2/r2/models/report.py
@@ -72,7 +72,7 @@ def new(cls, user, thing):
author._incr('reported')
item_age = datetime.now(g.tz) - thing._date
- if item_age.days < g.REPORT_AGE_LIMIT:
+ if item_age.days < g.REPORT_AGE_LIMIT and not thing.ignore_reports:
# update the reports queue if it exists
queries.new_report(thing, r)
@@ -80,7 +80,7 @@ def new(cls, user, thing):
if thing._spam:
cls.accept(thing)
else:
- g.log.debug("Ignoring old report %s" % r)
+ g.log.debug("Ignoring report %s" % r)
return r
View
10 r2/r2/public/static/css/reddit.css
@@ -5668,7 +5668,9 @@ body:not(.gold) .allminus-link {
.modactions.wikibanned,
.modactions.wikiunbanned,
.modactions.wikicontributor,
-.modactions.removewikicontributor {
+.modactions.removewikicontributor,
+.modactions.ignorereports,
+.modactions.unignorereports {
height: 16px;
width: 16px;
display: block;
@@ -5739,6 +5741,12 @@ body:not(.gold) .allminus-link {
.modactions.removewikicontributor {
background-image: url(../modactions_removecontributor.png); /* SPRITE */
}
+.modactions.ignorereports {
+ background-image: url(../modactions_mute.png); /* SPRITE */
+}
+.modactions.unignorereports {
+ background-image: url(../modactions_unmute.png); /* SPRITE */
+}
.adminpasswordform {
display: block;
View
7 r2/r2/public/static/js/reddit.js
@@ -1201,6 +1201,13 @@ function big_mod_action(elem, dir) {
return false;
}
+function big_mod_toggle(el, press_action, unpress_action) {
+ el.toggleClass('pressed')
+ $.request(el.is('.pressed') ? press_action : unpress_action, {
+ id: el.thing_id()
+ }, null, true)
+ return false
+}
/* The ready method */
$(function() {
View
BIN  r2/r2/public/static/modactions_mute.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  r2/r2/public/static/modactions_unmute.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
45 r2/r2/templates/printablebuttons.html
@@ -122,25 +122,33 @@
%endif
</%def>
+<%def name="ignore_reports_toggle(pressed)">
+ ${pretty_button(_("ignore reports"), "big_mod_toggle", "'ignore_reports', 'unignore_reports'", "neutral" + (" pressed" if pressed else ""))}
+</%def>
+
<%def name="big_modbuttons(thing, kind)">
<span class="big-mod-buttons">
- %if getattr(thing, "moderator_banned", None):
- <!-- pass -->
- %elif thing._spam:
- ${pretty_button(_("confirm spam"), "big_mod_action", -2, "negative")}
- ${pretty_button(_("remove ham"), "big_mod_action", -1, "neutral")}
- %else:
- ${pretty_button(_("spam"), "big_mod_action", -2, "negative")}
- ${pretty_button(_("remove"), "big_mod_action", -1, "neutral")}
- %endif
+ <span role="radiogroup">
+ %if getattr(thing, "moderator_banned", None):
+ <!-- pass -->
+ %elif thing._spam:
+ ${pretty_button(_("confirm spam"), "big_mod_action", -2, "negative")}
+ ${pretty_button(_("remove ham"), "big_mod_action", -1, "neutral")}
+ %else:
+ ${pretty_button(_("spam"), "big_mod_action", -2, "negative")}
+ ${pretty_button(_("remove"), "big_mod_action", -1, "neutral")}
+ %endif
+
+ %if getattr(thing, "approval_checkmark", None):
+ ${pretty_button(_("reapprove %(obj)s") % dict(obj=kind),
+ "big_mod_action", 1, "positive")}
+ %else:
+ ${pretty_button(_("approve %(obj)s") % dict(obj=kind),
+ "big_mod_action", 1, "positive")}
+ %endif
+ </span>
- %if getattr(thing, "approval_checkmark", None):
- ${pretty_button(_("reapprove %(obj)s") % dict(obj=kind),
- "big_mod_action", 1, "positive")}
- %else:
- ${pretty_button(_("approve %(obj)s") % dict(obj=kind),
- "big_mod_action", 1, "positive")}
- %endif
+ ${ignore_reports_toggle(pressed=thing.ignore_reports)}
&#32;
<span class="status-msg spammed">
@@ -243,8 +251,9 @@
%if getattr(thing.thing, "use_big_modbuttons", False):
${big_modbuttons(thing.thing, "link")}
+ %elif thing.ignore_reports and thing.can_ban:
+ ${ignore_reports_toggle(pressed=True)}
%endif
-
</%def>
<%def name="commentbuttons()">
@@ -315,6 +324,8 @@
%endif
%if getattr(thing.thing, "use_big_modbuttons", False):
${big_modbuttons(thing.thing, "comment")}
+ %elif thing.ignore_reports and thing.can_ban:
+ ${ignore_reports_toggle(pressed=True)}
%endif
%endif
</%def>

No commit comments for this range

Something went wrong with that request. Please try again.