mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-26 23:39:11 -05:00
More functional spam and remove buttons on all items.
This commit is contained in:
@@ -1432,24 +1432,39 @@ class ApiController(RedditController):
|
||||
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 = {'target': thing}
|
||||
if thing._spam:
|
||||
kw['details'] = 'dismiss'
|
||||
elif not spam:
|
||||
kw['details'] = 'not_spam'
|
||||
# Don't remove a promoted link
|
||||
if getattr(thing, "promoted", None):
|
||||
return
|
||||
|
||||
admintools.spam(thing, auto=False,
|
||||
moderator_banned=not c.user_is_admin,
|
||||
banner=c.user.name,
|
||||
train_spam=spam)
|
||||
end_trial(thing, why + "-removed")
|
||||
|
||||
if isinstance(thing, (Link, Comment)):
|
||||
sr = thing.subreddit_slow
|
||||
action = 'remove' + thing.__class__.__name__.lower()
|
||||
ModAction.create(sr, c.user, action, **kw)
|
||||
filtered = thing._spam
|
||||
kw = {'target': thing}
|
||||
|
||||
if filtered and spam:
|
||||
kw['details'] = 'confirm_spam'
|
||||
train_spam = False
|
||||
elif filtered and not spam:
|
||||
kw['details'] = 'remove'
|
||||
admintools.unspam(thing, unbanner=c.user.name, insert=False)
|
||||
train_spam = False
|
||||
elif not filtered and spam:
|
||||
kw['details'] = 'spam'
|
||||
train_spam = True
|
||||
elif not filtered and not spam:
|
||||
kw['details'] = 'remove'
|
||||
train_spam = False
|
||||
|
||||
admintools.spam(thing, auto=False,
|
||||
moderator_banned=not c.user_is_admin,
|
||||
banner=c.user.name,
|
||||
train_spam=train_spam)
|
||||
|
||||
if isinstance(thing, (Link, Comment)):
|
||||
sr = thing.subreddit_slow
|
||||
action = 'remove' + thing.__class__.__name__.lower()
|
||||
ModAction.create(sr, c.user, action, **kw)
|
||||
|
||||
@noresponse(VUser(), VModhash(),
|
||||
why = VSrCanBan('id'),
|
||||
@@ -1458,15 +1473,20 @@ class ApiController(RedditController):
|
||||
if not thing: return
|
||||
if thing._deleted: return
|
||||
end_trial(thing, why + "-approved")
|
||||
kw = {}
|
||||
kw = {'target': thing}
|
||||
if thing._spam:
|
||||
kw['details'] = 'unspam'
|
||||
admintools.unspam(thing, c.user.name)
|
||||
sr = thing.subreddit_slow
|
||||
if isinstance(thing, Link):
|
||||
ModAction.create(sr, c.user, 'approvelink', target=thing, **kw)
|
||||
elif isinstance(thing, Comment):
|
||||
ModAction.create(sr, c.user, 'approvecomment', target=thing, **kw)
|
||||
train_spam = True
|
||||
else:
|
||||
kw['details'] = 'confirm_ham'
|
||||
train_spam = False
|
||||
|
||||
admintools.unspam(thing, c.user.name, train_spam=train_spam)
|
||||
|
||||
if isinstance(thing, (Link, Comment)):
|
||||
sr = thing.subreddit_slow
|
||||
action = 'approve' + thing.__class__.__name__.lower()
|
||||
ModAction.create(sr, c.user, action, **kw)
|
||||
|
||||
@validatedForm(VUser(), VModhash(),
|
||||
VCanDistinguish(('id', 'how')),
|
||||
|
||||
@@ -46,19 +46,28 @@ class AdminTools(object):
|
||||
if getattr(t, "promoted", None) is not None:
|
||||
g.log.debug("Refusing to mark promotion %r as spam" % t)
|
||||
continue
|
||||
t._spam = True
|
||||
ban_info = copy(getattr(t, 'ban_info', {}))
|
||||
ban_info.update(auto = auto,
|
||||
moderator_banned = moderator_banned,
|
||||
banned_at = date or datetime.now(g.tz),
|
||||
**kw)
|
||||
|
||||
if not t._spam and train_spam:
|
||||
note = 'spam'
|
||||
elif not t._spam and not train_spam:
|
||||
note = 'remove not spam'
|
||||
elif t._spam and not train_spam:
|
||||
note = 'confirm spam'
|
||||
elif t._spam and train_spam:
|
||||
note = 'reinforce spam'
|
||||
|
||||
t._spam = True
|
||||
|
||||
ban_info = copy(getattr(t, 'ban_info', {}))
|
||||
if isinstance(banner, dict):
|
||||
ban_info['banner'] = banner[t._fullname]
|
||||
else:
|
||||
ban_info['banner'] = banner
|
||||
|
||||
ban_info['not_spam'] = not train_spam
|
||||
ban_info.update(auto=auto,
|
||||
moderator_banned=moderator_banned,
|
||||
banned_at=date or datetime.now(g.tz),
|
||||
**kw)
|
||||
ban_info['note'] = note
|
||||
|
||||
t.ban_info = ban_info
|
||||
t._commit()
|
||||
@@ -69,7 +78,7 @@ class AdminTools(object):
|
||||
|
||||
queries.ban(new_things)
|
||||
|
||||
def unspam(self, things, unbanner = None):
|
||||
def unspam(self, things, unbanner=None, train_spam=True, insert=True):
|
||||
from r2.lib.db import queries
|
||||
|
||||
things = tup(things)
|
||||
@@ -95,11 +104,11 @@ class AdminTools(object):
|
||||
t._spam = False
|
||||
t._commit()
|
||||
|
||||
# auto is always False for unbans
|
||||
self.author_spammer(things, False)
|
||||
self.set_last_sr_ban(things)
|
||||
|
||||
queries.unban(things)
|
||||
if insert:
|
||||
queries.unban(things)
|
||||
|
||||
def author_spammer(self, things, spam):
|
||||
"""incr/decr the 'spammer' field for the author of every
|
||||
|
||||
@@ -238,8 +238,8 @@ class Builder(object):
|
||||
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)'
|
||||
if ban_info.get('note', None) and w.banner:
|
||||
w.banner += ' (%s)' % ban_info['note']
|
||||
w.use_big_modbuttons = True
|
||||
if getattr(w, "author", None) and w.author._spam:
|
||||
w.show_spam = "author"
|
||||
|
||||
@@ -60,10 +60,11 @@ class ModAction(tdb_cassandra.UuidThing, Printable):
|
||||
|
||||
_details_text = {# approve comment/link
|
||||
'unspam': _('unspam'),
|
||||
'confirm_ham': _('confirmed ham'),
|
||||
# remove comment/link
|
||||
'confirm_spam': _('confirmed spam'), # vestigal
|
||||
'not_spam': _('not spam'),
|
||||
'dismiss': _('dismissed'),
|
||||
'confirm_spam': _('confirmed spam'),
|
||||
'remove': _('removed not spam'),
|
||||
'spam': _('removed spam'),
|
||||
# removemoderator
|
||||
'remove_self': _('removed self'),
|
||||
# editsettings
|
||||
|
||||
@@ -119,17 +119,14 @@
|
||||
|
||||
<%def name="big_modbuttons(thing, kind)">
|
||||
<span class="big-mod-buttons">
|
||||
<% remove_text = _('removed') %>
|
||||
%if getattr(thing, "moderator_banned", None):
|
||||
<!-- pass -->
|
||||
%elif thing._spam:
|
||||
${pretty_button(_("dismiss"), "big_mod_action", -1, "neutral")}
|
||||
<% remove_text = _('dismissed') %>
|
||||
${pretty_button(_("confirm spam"), "big_mod_action", -2, "negative")}
|
||||
${pretty_button(_("remove ham"), "big_mod_action", -1, "neutral")}
|
||||
%else:
|
||||
${pretty_button(_("spam %(obj)s") % dict(obj=kind),
|
||||
"big_mod_action", -2, "negative")}
|
||||
${pretty_button(_("remove %(obj)s") % dict(obj=kind),
|
||||
"big_mod_action", -1, "neutral")}
|
||||
${pretty_button(_("spam"), "big_mod_action", -2, "negative")}
|
||||
${pretty_button(_("remove"), "big_mod_action", -1, "neutral")}
|
||||
%endif
|
||||
|
||||
%if getattr(thing, "approval_checkmark", None):
|
||||
@@ -145,7 +142,7 @@
|
||||
${_("spammed")}
|
||||
</span>
|
||||
<span class="status-msg removed">
|
||||
${remove_text}
|
||||
${_("removed")}
|
||||
</span>
|
||||
<span class="status-msg approved">
|
||||
${_("approved")}
|
||||
|
||||
Reference in New Issue
Block a user