From 8e212ca459711c11ccf09bcc794bd4dca498f383 Mon Sep 17 00:00:00 2001 From: Jason Harvey Date: Fri, 8 Feb 2013 16:43:18 -0800 Subject: [PATCH] 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. --- r2/r2/controllers/api.py | 34 ++++++++++++++++++++ r2/r2/models/link.py | 5 ++- r2/r2/models/modaction.py | 14 +++++--- r2/r2/models/report.py | 4 +-- r2/r2/public/static/css/reddit.css | 10 +++++- r2/r2/public/static/js/reddit.js | 2 ++ r2/r2/public/static/modactions_mute.png | Bin 0 -> 474 bytes r2/r2/public/static/modactions_unmute.png | Bin 0 -> 610 bytes r2/r2/templates/printablebuttons.html | 37 +++++++++++++--------- 9 files changed, 83 insertions(+), 23 deletions(-) create mode 100644 r2/r2/public/static/modactions_mute.png create mode 100644 r2/r2/public/static/modactions_unmute.png diff --git a/r2/r2/controllers/api.py b/r2/r2/controllers/api.py index 8c20d2079..4d0293fdc 100755 --- a/r2/r2/controllers/api.py +++ b/r2/r2/controllers/api.py @@ -1062,6 +1062,8 @@ class ApiController(RedditController, OAuth2ResourceController): or (item._ups + item._downs > 2)): item.editted = c.start_time + item.ignore_reports = False + item._commit() changed(item) @@ -1855,6 +1857,38 @@ class ApiController(RedditController, OAuth2ResourceController): action = 'approve' + thing.__class__.__name__.lower() 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')), diff --git a/r2/r2/models/link.py b/r2/r2/models/link.py index 9401975b2..df66b9398 100755 --- a/r2/r2/models/link.py +++ b/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) @@ -689,7 +690,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): diff --git a/r2/r2/models/modaction.py b/r2/r2/models/modaction.py index f4697b10b..c62b8e5ac 100644 --- a/r2/r2/models/modaction.py +++ b/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) diff --git a/r2/r2/models/report.py b/r2/r2/models/report.py index 20183d75f..2a4b307dd 100644 --- a/r2/r2/models/report.py +++ b/r2/r2/models/report.py @@ -72,7 +72,7 @@ class Report(MultiRelation('report', 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 @@ class Report(MultiRelation('report', if thing._spam: cls.accept(thing) else: - g.log.debug("Ignoring old report %s" % r) + g.log.debug("Ignoring report %s" % r) return r diff --git a/r2/r2/public/static/css/reddit.css b/r2/r2/public/static/css/reddit.css index 7f5176226..d6363ff66 100755 --- a/r2/r2/public/static/css/reddit.css +++ b/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; diff --git a/r2/r2/public/static/js/reddit.js b/r2/r2/public/static/js/reddit.js index b179f9f50..8006fc0b1 100644 --- a/r2/r2/public/static/js/reddit.js +++ b/r2/r2/public/static/js/reddit.js @@ -1195,6 +1195,8 @@ function big_mod_action(elem, dir) { } else if (dir == 1) { $.request("approve", d, null, true); elem.siblings(".approved").show(); + } else if (dir == 2) { + $.request("ignore_reports", d, null, true); } } elem.siblings(".pretty-button").removeClass("pressed"); diff --git a/r2/r2/public/static/modactions_mute.png b/r2/r2/public/static/modactions_mute.png new file mode 100644 index 0000000000000000000000000000000000000000..b652d2a71fc0e866d855c08f415b7ec057b3cee9 GIT binary patch literal 474 zcmV<00VV#4P)VI0N<*QWk}{)T2Jp~1;rnJ&N2haulNhlC*Od9Gf>KFEtyV>~T1KT( zMys`lcDs%9Y!**GpCvG7uAr)U^!sP%^?K-byD$s`r=o}<$KlrRw*+%D1$0-K<~|ff zfh@~77KHKSyI>I8i8yRaw2IR8ItU>!0|7iT3@*K1Y{mtMqF^t`<+5lr>Nw*0@#HI( zfyeDeD71=LjJFr0(_1)Hq)$07*qoM6N<$f*zgBZU6uP literal 0 HcmV?d00001 diff --git a/r2/r2/public/static/modactions_unmute.png b/r2/r2/public/static/modactions_unmute.png new file mode 100644 index 0000000000000000000000000000000000000000..6056d234a9818d248987389d4a621e5c83ce0851 GIT binary patch literal 610 zcmV-o0-gPdP)FDRfPcVFW5d%9V=z{?A#;oriL5xO+n6O2X~nf!lQuE^VWXpgu83qI(qCF{ zS}dqc=wWy-JjhR6YYDxINHb)T^nMSh)vA20R`F7)lzCSCZF94My}d73T>N+m zpyXWPL`#FF;s+j3t(LL2R!6+EP98p9G9EaJe<5S)o@#CPu0JyV*YBbiNC<>y{C`3_2 zFc^fUC0P=`0GC2D0rmxry!i<{eh#|t2UjSV*w|QyY37m5W)KQZKoA6m%^;bK|K7sb zq~^Y!1U(%y>Cs5W^^bz?JUQeR7IK)M&$43OYdMwDJVcVBtSjl_Ar8Hmr2)a$eK-tv zNC4d)(7D`Piq~gVUR7m2k$BH5O6=$i%I6Kpa_sVNy!&j)9UKPT@*VWNNNm+UIUciF wPJ00!a`S;oH}3WS@hUTDnx*^y9@F3E2OYGed{u8eJ^%m!07*qoM6N<$f+a~A3jhEB literal 0 HcmV?d00001 diff --git a/r2/r2/templates/printablebuttons.html b/r2/r2/templates/printablebuttons.html index d65f2eeaa..b5e0a4f26 100644 --- a/r2/r2/templates/printablebuttons.html +++ b/r2/r2/templates/printablebuttons.html @@ -124,22 +124,29 @@ <%def name="big_modbuttons(thing, kind)"> - %if getattr(thing, "moderator_banned", None): - - %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, "moderator_banned", None): + + %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 + - %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")} + %if not thing.ignore_reports: + ${pretty_button(_("ignore reports"), + "big_mod_action", 2, "neutral")} %endif