From 01dcdad9a9fb220d8627eb8f8fde467bd1309d7b Mon Sep 17 00:00:00 2001
From: jordan
Date: Sat, 3 Dec 2011 14:29:28 +0000
Subject: [PATCH] adding recaptcha anti-spam fields to the feedback form
git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@1206 0cfe37f9-358a-4d5e-be75-b63607b5c754
---
forum/forms/qanda.py | 11 ++++++++
forum/skins/default/templates/feedback.html | 28 ++++++++++++++++-----
2 files changed, 33 insertions(+), 6 deletions(-)
diff --git a/forum/forms/qanda.py b/forum/forms/qanda.py
index a81279b..e356f07 100644
--- a/forum/forms/qanda.py
+++ b/forum/forms/qanda.py
@@ -158,6 +158,17 @@ class FeedbackForm(forms.Form):
self.fields['name'] = forms.CharField(label=_('Your name:'), required=False)
self.fields['email'] = forms.EmailField(label=_('Email (not shared with anyone):'), required=True)
+ # Create anti spam fields
+ spam_fields = call_all_handlers('create_anti_spam_field')
+ if spam_fields:
+ spam_fields = dict(spam_fields)
+ for name, field in spam_fields.items():
+ self.fields[name] = field
+
+ self._anti_spam_fields = spam_fields.keys()
+ else:
+ self._anti_spam_fields = []
+
class AskForm(forms.Form):
diff --git a/forum/skins/default/templates/feedback.html b/forum/skins/default/templates/feedback.html
index f4a4781..690e943 100644
--- a/forum/skins/default/templates/feedback.html
+++ b/forum/skins/default/templates/feedback.html
@@ -27,24 +27,40 @@
Please type and send us your message below.
{% endblocktrans %}
-
{{form.name}}
+
{{form.name}}
-
{% endif %}
- {{form.message.label}}
+ {{form.message.label}}
{% if form.errors.message %}
- {% trans "(this field is required)" %}
-
+ {% trans "(this field is required)" %}
{% endif %}
+
{{form.message}}
+
+ {% if form.recaptcha %}
+
+ Are you a human?
+ {% if form.errors.recaptcha %}
+ {% trans "(wrong captcha)" %}
+ {% endif %}
+
+
+