Subreddit options: Include more fine-grained spam controls

This commit is contained in:
Roger Ostrander
2013-07-30 16:53:42 -07:00
parent 0b7bc86ea4
commit 5f6ba13aaf
4 changed files with 60 additions and 2 deletions

View File

@@ -1790,6 +1790,9 @@ class ApiController(RedditController, OAuth2ResourceController):
public_traffic = VBoolean('public_traffic'),
exclude_banned_modqueue = VBoolean('exclude_banned_modqueue'),
show_cname_sidebar = VBoolean('show_cname_sidebar'),
spam_links = VOneOf('spam_links', ('low', 'high')),
spam_selfposts = VOneOf('spam_selfposts', ('low', 'high')),
spam_comments = VOneOf('spam_comments', ('low', 'high')),
type = VOneOf('type', ('public', 'private', 'restricted', 'gold_restricted', 'archived')),
link_type = VOneOf('link_type', ('any', 'link', 'self')),
submit_link_label=VLength('submit_link_label', max_length=60),
@@ -1829,7 +1832,7 @@ class ApiController(RedditController, OAuth2ResourceController):
c.errors.add(errors.BAD_REVISION, field=id_field_name)
form.has_errors(id_field_name, errors.BAD_REVISION)
return False
# the status button is outside the form -- have to reset by hand
form.parent().set_html('.status', "")
@@ -1842,7 +1845,8 @@ class ApiController(RedditController, OAuth2ResourceController):
'submit_link_label', 'comment_score_hide_mins',
'submit_text_label', 'lang', 'css_on_cname',
'header_title', 'over_18', 'wikimode', 'wiki_edit_karma',
'wiki_edit_age', 'allow_top', 'public_description'))
'wiki_edit_age', 'allow_top', 'public_description',
'spam_links', 'spam_selfposts', 'spam_comments'))
public_description = kw.pop('public_description')
description = kw.pop('description')

View File

@@ -223,6 +223,9 @@ class Subreddit(Thing, Printable, BaseSite):
allow_comment_gilding=True,
hide_subscribers=False,
public_traffic=False,
spam_links='high',
spam_selfposts='high',
spam_comments='low',
)
_essentials = ('type', 'name', 'lang')
_data_int_props = Thing._data_int_props + ('mod_actions', 'reported',

View File

@@ -217,6 +217,42 @@
</div>
</div>
</%utils:line_field>
<%utils:line_field title="${_('spam filter strength')}"
description='${_("high is the standard filter, low disables most filtering")}'>
<div class="delete-field">
<table>
<tr>
<td>${_("links")}:</td>
<td>
${utils.inline_radio_type('spam_links', 'low', _("low"),
checked=thing.site and thing.site.spam_links == 'low')}
${utils.inline_radio_type('spam_links', 'high', _("high"),
checked=thing.site and thing.site.spam_links == 'high')}
</td>
</tr>
<tr>
<td>${_("self posts")}:</td>
<td>
${utils.inline_radio_type('spam_selfposts', 'low', _("low"),
checked=thing.site and thing.site.spam_selfposts == 'low')}
${utils.inline_radio_type('spam_selfposts', 'high', _("high"),
checked=thing.site and thing.site.spam_selfposts == 'high')}
</td>
</tr>
<tr>
<td>${_("comments")}:</td>
<td>
${utils.inline_radio_type('spam_comments', 'low', _("low"),
checked=thing.site and thing.site.spam_comments == 'low')}
${utils.inline_radio_type('spam_comments', 'high', _("high"),
checked=thing.site and thing.site.spam_comments == 'high')}
</td>
</tr>
</table>
</div>
</%utils:line_field>
<%utils:line_field title="${_('other options')}">
<div class="delete-field">
<ul>

View File

@@ -529,6 +529,21 @@ ${unsafe(txt)}
</tr>
</%def>
<%def name="inline_radio_type(field_name, val_name, text=None, checked=False)">
<% full_name = field_name + "_" + val_name %>
<label>
<input class="nomargin" type="radio" name="${field_name}"
id="${full_name}" value="${val_name}"
%if checked:
checked="checked"
%endif
>
%if text:
${text}
%endif
</label>
</%def>
<%def name="timestamp(date, since=None)">
## todo: use pubdate attribute once things are <article> tags.
## note: comment and link templates will pass a CachedVariable stub as since.