本文整理汇总了Python中r2.models.Report.accept方法的典型用法代码示例。如果您正苦于以下问题:Python Report.accept方法的具体用法?Python Report.accept怎么用?Python Report.accept使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类r2.models.Report
的用法示例。
在下文中一共展示了Report.accept方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: unspam
# 需要导入模块: from r2.models import Report [as 别名]
# 或者: from r2.models.Report import accept [as 别名]
def unspam(self, things, unbanner=None, train_spam=True, insert=True):
from r2.lib.db import queries
things = tup(things)
# We want to make unban-all moderately efficient, so when
# mass-unbanning, we're going to skip the code below on links that
# are already not banned. However, when someone manually clicks
# "approve" on an unbanned link, and there's just one, we want do
# want to run the code below. That way, the little green checkmark
# will have the right mouseover details, the reports will be
# cleared, etc.
if len(things) > 1:
things = [x for x in things if x._spam]
Report.accept(things, False)
for t in things:
ban_info = copy(getattr(t, 'ban_info', {}))
ban_info['unbanned_at'] = datetime.now(g.tz)
if unbanner:
ban_info['unbanner'] = unbanner
if ban_info.get('reset_used', None) == None:
ban_info['reset_used'] = False
else:
ban_info['reset_used'] = True
t.ban_info = ban_info
t._spam = False
t._commit()
self.author_spammer(things, False)
self.set_last_sr_ban(things)
queries.unban(things, insert)
示例2: spam
# 需要导入模块: from r2.models import Report [as 别名]
# 或者: from r2.models.Report import accept [as 别名]
def spam(self, things, auto, moderator_banned, banner, date = None, **kw):
from r2.lib.db import queries
things = [x for x in tup(things) if not x._spam]
Report.accept(things, True)
for t in things:
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 isinstance(banner, dict):
ban_info['banner'] = banner[t._fullname]
else:
ban_info['banner'] = banner
t.ban_info = ban_info
t._commit()
changed(t)
if not auto:
self.author_spammer(things, True)
self.set_last_sr_ban(things)
queries.ban(things)
示例3: spam
# 需要导入模块: from r2.models import Report [as 别名]
# 或者: from r2.models.Report import accept [as 别名]
def spam(self, things, auto=True, moderator_banned=False,
banner=None, date = None, **kw):
from r2.lib.db import queries
all_things = tup(things)
new_things = [x for x in all_things if not x._spam]
# No need to accept reports on things with _spam=True,
# since nobody can report them in the first place.
Report.accept(new_things, True)
for t in all_things:
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 isinstance(banner, dict):
ban_info['banner'] = banner[t._fullname]
else:
ban_info['banner'] = banner
t.ban_info = ban_info
t._commit()
if not auto:
self.author_spammer(new_things, True)
self.set_last_sr_ban(new_things)
queries.ban(new_things)
示例4: spam
# 需要导入模块: from r2.models import Report [as 别名]
# 或者: from r2.models.Report import accept [as 别名]
def spam(self, things, auto=True, moderator_banned=False,
banner=None, date=None, train_spam=True, **kw):
from r2.lib.db import queries
all_things = tup(things)
new_things = [x for x in all_things if not x._spam]
Report.accept(all_things, True)
for t in all_things:
if getattr(t, "promoted", None) is not None:
g.log.debug("Refusing to mark promotion %r as spam" % t)
continue
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
if moderator_banned:
t.verdict = 'mod-removed'
elif not auto:
t.verdict = 'admin-removed'
ban_info = copy(getattr(t, 'ban_info', {}))
if isinstance(banner, dict):
ban_info['banner'] = banner[t._fullname]
else:
ban_info['banner'] = banner
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()
if auto:
amqp.add_item("auto_removed", t._fullname)
if not auto:
self.author_spammer(new_things, True)
self.set_last_sr_ban(new_things)
queries.ban(all_things, filtered=auto)
示例5: unspam
# 需要导入模块: from r2.models import Report [as 别名]
# 或者: from r2.models.Report import accept [as 别名]
def unspam(self, things, unbanner = None):
Report.accept(things, False)
things = [ x for x in tup(things) if x._spam ]
for t in things:
ban_info = copy(getattr(t, 'ban_info', {}))
ban_info['unbanned_at'] = datetime.now(g.tz)
if unbanner:
ban_info['unbanner'] = unbanner
t.ban_info = ban_info
t._spam = False
t._commit()
changed(t)
self.author_spammer(things, False)
queries.unban(things)
示例6: unspam
# 需要导入模块: from r2.models import Report [as 别名]
# 或者: from r2.models.Report import accept [as 别名]
def unspam(self, things, moderator_unbanned=True, unbanner=None,
train_spam=True, insert=True):
from r2.lib.db import queries
things = tup(things)
# We want to make unban-all moderately efficient, so when
# mass-unbanning, we're going to skip the code below on links that
# are already not banned. However, when someone manually clicks
# "approve" on an unbanned link, and there's just one, we want do
# want to run the code below. That way, the little green checkmark
# will have the right mouseover details, the reports will be
# cleared, etc.
if len(things) > 1:
things = [x for x in things if x._spam]
Report.accept(things, False)
inbox_adjustment_counter = Counter()
for t in things:
ban_info = copy(getattr(t, 'ban_info', {}))
ban_info['unbanned_at'] = datetime.now(g.tz)
if unbanner:
ban_info['unbanner'] = unbanner
if ban_info.get('reset_used', None) == None:
ban_info['reset_used'] = False
else:
ban_info['reset_used'] = True
t.ban_info = ban_info
if isinstance(t, Message) and t._spam and t.to_id:
inbox_adjustment_counter[t.to_id] += 1
t._spam = False
if moderator_unbanned:
t.verdict = 'mod-approved'
else:
t.verdict = 'admin-approved'
t._commit()
if isinstance(t, Comment):
amqp.add_item("approved_comment", t._fullname)
elif isinstance(t, Link):
amqp.add_item("approved_link", t._fullname)
self.author_spammer(things, False)
self.set_last_sr_ban(things)
queries.unban(things, insert)
self.adjust_inbox_counts(inbox_adjustment_counter)
示例7: spam
# 需要导入模块: from r2.models import Report [as 别名]
# 或者: from r2.models.Report import accept [as 别名]
def spam(self, things, auto, moderator_banned, banner, date = None, **kw):
Report.accept(things, True)
things = [ x for x in tup(things) if not x._spam ]
for t in things:
t._spam = True
ban_info = copy(getattr(t, 'ban_info', {}))
ban_info.update(auto = auto,
moderator_banned = moderator_banned,
banner = banner,
banned_at = date or datetime.now(g.tz),
**kw)
t.ban_info = ban_info
t._commit()
changed(t)
self.author_spammer(things, True)
queries.ban(things)
示例8: unspam
# 需要导入模块: from r2.models import Report [as 别名]
# 或者: from r2.models.Report import accept [as 别名]
def unspam(self, things, unbanner = None):
from r2.lib.db import queries
things = [x for x in tup(things) if x._spam]
Report.accept(things, False)
for t in things:
ban_info = copy(getattr(t, 'ban_info', {}))
ban_info['unbanned_at'] = datetime.now(g.tz)
if unbanner:
ban_info['unbanner'] = unbanner
t.ban_info = ban_info
t._spam = False
t._commit()
changed(t)
# auto is always False for unbans
self.author_spammer(things, False)
self.set_last_sr_ban(things)
queries.unban(things)