This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Allow subreddits to exclude banned users' posts from their modqueue

Many subreddits just use scripts or AutoModerator to automatically
confirm removal of all posts by site-wide banned users from their
modqueue. This will eliminate the need for third-party tools for it.
  • Loading branch information...
Deimos committed Mar 3, 2013
1 parent bfe3b35 commit 9691a1ae9177843568bc3a9f37696b743bed9a3d
View
@@ -1673,6 +1673,7 @@ def POST_upload_sr_img(self, file, header, sponsor, name, form_id, img_type):
over_18 = VBoolean('over_18'),
allow_top = VBoolean('allow_top'),
show_media = VBoolean('show_media'),
+ exclude_banned_modqueue = VBoolean('exclude_banned_modqueue'),
show_cname_sidebar = VBoolean('show_cname_sidebar'),
type = VOneOf('type', ('public', 'private', 'restricted', 'archived')),
link_type = VOneOf('link_type', ('any', 'link', 'self')),
@@ -1723,6 +1724,7 @@ def apply_wikid_field(sr, form, pagename, value, prev, field, error):
if k in ('name', 'title', 'domain', 'description',
'show_media', 'show_cname_sidebar', 'type', 'link_type', 'lang',
'css_on_cname', 'header_title', 'over_18',
+ 'exclude_banned_modqueue',
'wikimode', 'wiki_edit_karma', 'wiki_edit_age',
'allow_top', 'public_description'))
@@ -532,6 +532,10 @@ def keep_fn(x):
elif location == "modqueue":
if x.reported > 0 and not x._spam:
return True # reported but not banned
+ if x.author._spam and x.subreddit.exclude_banned_modqueue:
+ # banned user, don't show if subreddit pref excludes
+ return False
+
verdict = getattr(x, "verdict", None)
if verdict is None:
return True # anything without a verdict
View
@@ -857,7 +857,8 @@ def new_comment(comment, inbox_rels):
job_key = "insert_items"
if comment._spam:
m.insert(get_spam_comments(sr), [comment])
- if was_spam_filtered(comment):
+ if (was_spam_filtered(comment) and
+ not (sr.exclude_banned_modqueue and author._spam)):
m.insert(get_spam_filtered_comments(sr), [comment])
if utils.to36(comment.link_id) in g.live_config["fastlane_links"]:
@@ -1124,27 +1125,46 @@ def ban(things, filtered=True):
by_srid = _by_srid(things, srs=False)
for sr_id, sr_things in by_srid.iteritems():
- links = [x for x in sr_things if isinstance(x, Link)]
- comments = [x for x in sr_things if isinstance(x, Comment)]
+ links = []
+ modqueue_links = []
+ comments = []
+ modqueue_comments = []
+ for item in sr_things:
+ # don't add posts by banned users if subreddit prefs exclude them
+ add_to_modqueue = (filtered and
+ not (item.subreddit_slow.exclude_banned_modqueue and
+ item.author_slow._spam))
+
+ if isinstance(item, Link):
+ links.append(item)
+ if add_to_modqueue:
+ modqueue_links.append(item)
+ elif isinstance(item, Comment):
+ comments.append(item)
+ if add_to_modqueue:
+ modqueue_comments.append(item)
if links:
query_cache_inserts.append((get_spam_links(sr_id), links))
- if filtered:
- query_cache_inserts.append((get_spam_filtered_links(sr_id),
- links))
- else:
- query_cache_deletes.append((get_spam_filtered_links(sr_id),
- links))
- query_cache_deletes.append((get_unmoderated_links(sr_id),
- links))
+ if not filtered:
+ query_cache_deletes.append(
+ (get_spam_filtered_links(sr_id), links))
+ query_cache_deletes.append(
+ (get_unmoderated_links(sr_id), links))
+
+ if modqueue_links:
+ query_cache_inserts.append(
+ (get_spam_filtered_links(sr_id), modqueue_links))
+
if comments:
query_cache_inserts.append((get_spam_comments(sr_id), comments))
- if filtered:
- query_cache_inserts.append((get_spam_filtered_comments(sr_id),
- comments))
- else:
- query_cache_deletes.append((get_spam_filtered_comments(sr_id),
- comments))
+ if not filtered:
+ query_cache_deletes.append(
+ (get_spam_filtered_comments(sr_id), comments))
+
+ if modqueue_comments:
+ query_cache_inserts.append(
+ (get_spam_filtered_comments(sr_id), modqueue_comments))
with CachedQueryMutator() as m:
for q, inserts in query_cache_inserts:
@@ -714,6 +714,7 @@ class SubredditSettingsTemplate(ThingJsonTemplate):
over_18 = 'site.over_18',
default_set = 'site.allow_top',
show_media = 'site.show_media',
+ exclude_banned_modqueue = 'site.exclude_banned_modqueue',
domain = 'site.domain',
domain_css = 'site.css_on_cname',
wikimode = 'site.wikimode',
View
@@ -600,11 +600,17 @@ def add_props(cls, user, wrapped):
@property
def subreddit_slow(self):
- from subreddit import Subreddit
- """return's a link's subreddit. in most case the subreddit is already
- on the wrapped link (as .subreddit), and that should be used
- when possible. """
- return Subreddit._byID(self.sr_id, True, return_dict=False)
+ """Returns the link's subreddit."""
+ # The subreddit is often already on the wrapped link as .subreddit
+ # If available, that should be used instead of calling this
+ return Subreddit._byID(self.sr_id, data=True, return_dict=False)
+
+ @property
+ def author_slow(self):
+ """Returns the link's author."""
+ # The author is often already on the wrapped link as .author
+ # If available, that should be used instead of calling this
+ return Account._byID(self.author_id, data=True, return_dict=False)
class LinksByUrl(tdb_cassandra.View):
_use_db = True
@@ -85,6 +85,7 @@ class Subreddit(Thing, Printable):
wiki_edit_karma = 100,
wiki_edit_age = 0,
over_18 = False,
+ exclude_banned_modqueue = False,
mod_actions = 0,
sponsorship_text = "this reddit is sponsored by",
sponsorship_url = None,
@@ -196,28 +196,49 @@
<div class="delete-field">
<ul>
<li>
- <input class="nomargin" type="checkbox" name="over_18" id="over_18"
- ${thing.site and thing.site.over_18 and "checked='checked'" or ""}/>
+ <input class="nomargin" type="checkbox"
+ name="over_18" id="over_18"
+ %if thing.site and thing.site.over_18:
+ checked="checked"
+ %endif
+ >
<label for="over_18">
${_("viewers must be over eighteen years old")}
</label>
</li>
<li>
- <input class="nomargin" type="checkbox"
+ <input class="nomargin" type="checkbox"
name="allow_top" id="allow_top"
- ${(not thing.site or thing.site.allow_top) and "checked='checked'" or ""}/>
+ %if not thing.site or thing.site.allow_top:
+ checked="checked"
+ %endif
+ >
<label for="allow_top">
${_("allow this reddit to be shown in the default set")}
</label>
</li>
<li>
- <input class="nomargin" type="checkbox"
+ <input class="nomargin" type="checkbox"
name="show_media" id="show_media"
- ${thing.site and thing.site.show_media and "checked='checked'" or ""}/>
+ %if thing.site and thing.site.show_media:
+ checked="checked"
+ %endif
+ >
<label for="show_media">
${_("show thumbnail images of content")}
</label>
</li>
+ <li>
+ <input class="nomargin" type="checkbox"
+ name="exclude_banned_modqueue" id="exclude_banned_modqueue"
+ %if thing.site and thing.site.exclude_banned_modqueue:
+ checked="checked"
+ %endif
+ >
+ <label for="exclude_banned_modqueue">
+ ${_("exclude posts by site-wide banned users from modqueue")}
+ </label>
+ </li>
</ul>
</div>
</%utils:line_field>
@@ -228,14 +249,20 @@
%if thing.site and c.site.domain:
<input class="nomargin" type="checkbox"
name="css_on_cname" id="css_on_cname"
- ${thing.site.css_on_cname and "checked='checked'" or ""}/>
+ %if thing.site.css_on_cname:
+ checked="checked"
+ %endif
+ >
<label for="css_on_cname">
${_("make custom CSS styles apply only when accessed from the cname.")}
</label>
<br/>
<input class="nomargin" type="checkbox"
name="show_cname_sidebar" id="show_cname_sidebar"
- ${thing.site and thing.site.show_cname_sidebar and "checked='checked'" or ""}/>
+ %if thing.site.show_cname_sidebar:
+ checked="checked"
+ %endif
+ >
<label for="show_cname_sidebar">
${_("show sidebar when accessed from the cname.")}
</label>

0 comments on commit 9691a1a

Please sign in to comment.