Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Remove things as spam or not spam.

  • Loading branch information...
commit 2a8876bfb6dd2700ab497411720360a2f215c08e 1 parent 1088fe7
@bsimpson63 bsimpson63 authored
View
28 r2/r2/controllers/api.py
@@ -1426,19 +1426,27 @@ def POST_searchfeedback(self, q, sort, t, approval):
@noresponse(VUser(), VModhash(),
why = VSrCanBan('id'),
- thing = VByName('id'))
- def POST_remove(self, why, thing):
+ thing = VByName('id'),
+ spam = VBoolean('spam', default=True))
+ def POST_remove(self, why, thing, spam):
if getattr(thing, "promoted", None) is None:
end_trial(thing, why + "-removed")
- kw = {}
- if thing._spam:
+
+ kw = {'target': thing}
+ if thing._spam and spam:
kw['details'] = 'confirm_spam'
- admintools.spam(thing, False, not c.user_is_admin, c.user.name)
- sr = thing.subreddit_slow
- if isinstance(thing, Link):
- ModAction.create(sr, c.user, 'removelink', target=thing, **kw)
- elif isinstance(thing, Comment):
- ModAction.create(sr, c.user, 'removecomment', target=thing, **kw)
+
+ admintools.spam(thing, auto=False,
+ moderator_banned=not c.user_is_admin,
+ banner=c.user.name,
+ train_spam=spam)
+
+ if isinstance(thing, (Link, Comment)):
+ if not spam:
+ kw['details'] = 'not_spam'
+ sr = thing.subreddit_slow
+ action = 'remove' + thing.__class__.__name__.lower()
+ ModAction.create(sr, c.user, action, **kw)
@noresponse(VUser(), VModhash(),
why = VSrCanBan('id'),
View
4 r2/r2/models/admintools.py
@@ -32,7 +32,7 @@
class AdminTools(object):
def spam(self, things, auto=True, moderator_banned=False,
- banner=None, date = None, **kw):
+ banner=None, date=None, train_spam=True, **kw):
from r2.lib.db import queries
all_things = tup(things)
@@ -58,6 +58,8 @@ def spam(self, things, auto=True, moderator_banned=False,
else:
ban_info['banner'] = banner
+ ban_info['not_spam'] = not train_spam
+
t.ban_info = ban_info
t._commit()
View
2  r2/r2/models/builder.py
@@ -238,6 +238,8 @@ def wrap_items(self, items):
w.moderator_banned = ban_info.get('moderator_banned', False)
w.autobanned = ban_info.get('auto', False)
w.banner = ban_info.get('banner')
+ if ban_info.get('not_spam', False) and w.banner:
+ w.banner += ' (not spam)'
w.use_big_modbuttons = True
if getattr(w, "author", None) and w.author._spam:
w.show_spam = "author"
View
1  r2/r2/models/modaction.py
@@ -62,6 +62,7 @@ class ModAction(tdb_cassandra.UuidThing, Printable):
'unspam': _('unspam'),
# remove comment/link
'confirm_spam': _('confirmed spam'),
+ 'not_spam': _('not spam'),
# removemoderator
'remove_self': _('removed self'),
# editsettings
View
5 r2/r2/templates/printablebuttons.html
@@ -41,7 +41,10 @@
%if not getattr(thing.thing, "use_big_modbuttons", False):
%if not thing.show_spam:
<li>
- ${ynbutton(_("remove"), _("removed"), "remove")}
+ ${ynbutton(_("spam"), _("spammed"), "remove")}
+ </li>
+ <li>
+ ${ynbutton(_("remove"), _("removed"), "remove", hidden_data=dict(spam=False))}
</li>
%endif
Please sign in to comment.
Something went wrong with that request. Please try again.