Mercurial > public > sg101
diff gpp/forums/views.py @ 215:8c1832b9d815
Implement #84; additional checks on spammers; implement stranger status.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sat, 29 May 2010 04:51:28 +0000 |
parents | db202792d9f5 |
children | fe900598f81c |
line wrap: on
line diff
--- a/gpp/forums/views.py Fri May 14 02:19:48 2010 +0000 +++ b/gpp/forums/views.py Sat May 29 04:51:28 2010 +0000 @@ -31,6 +31,9 @@ get_post_unread_status, get_unread_topics from bio.models import UserProfile +import antispam +import antispam.utils + ####################################################################### TOPICS_PER_PAGE = 50 @@ -225,6 +228,9 @@ if request.method == 'POST': form = NewTopicForm(request.user, forum, request.POST) if form.is_valid(): + if antispam.utils.spam_check(request, form.cleaned_data['body']): + return HttpResponseRedirect(reverse('antispam-suspended')) + topic = form.save(request.META.get("REMOTE_ADDR")) _bump_post_count(request.user) return HttpResponseRedirect(reverse('forums-new_topic_thanks', @@ -267,6 +273,8 @@ if form.is_valid(): if not _can_post_in_topic(form.topic, request.user): return HttpResponseForbidden("You don't have permission to post in this topic.") + if antispam.utils.spam_check(request, form.cleaned_data['body']): + return HttpResponseForbidden(antispam.BUSTED_MESSAGE) post = form.save(request.user, request.META.get("REMOTE_ADDR", "")) post.unread = True @@ -342,6 +350,8 @@ if request.method == "POST": form = PostForm(request.POST, instance=post) if form.is_valid(): + if antispam.utils.spam_check(request, form.cleaned_data['body']): + return HttpResponseRedirect(reverse('antispam-suspended')) post = form.save(commit=False) post.touch() post.save() @@ -462,6 +472,8 @@ if request.method == 'POST': form = PostForm(request.POST) if form.is_valid(): + if antispam.utils.spam_check(request, form.cleaned_data['body']): + return HttpResponseRedirect(reverse('antispam-suspended')) post = form.save(commit=False) post.topic = topic post.user = request.user