Permalink
Browse files

New spam_filters module, honeypot moved there.

  • Loading branch information...
1 parent 22cd28f commit 4b051d72717cc80f07497eeaadd85c0a509c9a20 @zsiciarz committed Nov 3, 2011
Showing with 22 additions and 7 deletions.
  1. +15 −0 envelope/spam_filters.py
  2. +7 −7 envelope/views.py
View
@@ -0,0 +1,15 @@
+# -*- coding: utf-8 -*-
+
+u"""
+Spam filters - functions that reject the message if it is considered spam.
+"""
+
+from honeypot.decorators import verify_honeypot_value
+
+
+def check_honeypot(request, form):
+ u"""
+ ``verify_honeypot_value`` returns ``None`` when everything is OK.
+ """
+ return verify_honeypot_value(request, '') is None
+
View
@@ -12,8 +12,6 @@
from django.utils.translation import ugettext_lazy as _
from django.views.generic import FormView
-from honeypot.decorators import verify_honeypot_value
-
from envelope import signals
from envelope.forms import ContactForm
@@ -107,11 +105,13 @@ def form_invalid(self, form):
return self.render_to_response(self.get_context_data(form=form))
-def check_honeypot(sender, request, form, **kwargs):
+def filter_spam(sender, request, form, **kwargs):
u"""
- ``verify_honeypot_value`` returns ``None`` when everything is OK.
+ Handle spam filtering.
"""
- return verify_honeypot_value(request, '') is None
+ from envelope.spam_filters import check_honeypot
+ return check_honeypot(request, form)
+
-signals.before_send.connect(check_honeypot, sender=ContactView,
- dispatch_uid='envelope.views')
+signals.before_send.connect(filter_spam, sender=ContactView,
+ dispatch_uid='envelope.views.filter_spam')

0 comments on commit 4b051d7

Please sign in to comment.