]> git.openstreetmap.org Git - osqa.git/commitdiff
adding recaptcha anti-spam fields to the feedback form
authorjordan <jordan@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Sat, 3 Dec 2011 14:29:28 +0000 (14:29 +0000)
committerjordan <jordan@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Sat, 3 Dec 2011 14:29:28 +0000 (14:29 +0000)
git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@1206 0cfe37f9-358a-4d5e-be75-b63607b5c754

forum/forms/qanda.py
forum/skins/default/templates/feedback.html

index a81279b2025e3c0103f09e608444b1cb9516dbbc..e356f0744655e1cb483035462145f235ed21add1 100644 (file)
@@ -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):
index f4a4781a9374a4f047be2254347c7615f8ff9e25..690e9439a73307315470d24b7250202149937922 100644 (file)
             Please type and send us your message below.
             {% endblocktrans %}
             </p>
-            <div class="form-row"><label>{{form.name.label}}</label><br/>{{form.name}}</div>
+            <div class="form-row"><label for="id_name">{{form.name.label}}</label><br/>{{form.name}}</div>
             <div class="form-row">
-                <label>{{form.email.label}} 
+                <label for="id_email">{{form.email.label}}
                     {% if form.errors.email %}
-                        <span class='red'>(please enter a valid email)</span>
+                        <strong>(please enter a valid email)</strong>
                     {% endif %}
                 </label><br/>{{form.email}}
             </div>
         {% endif %}
         <div class="form-row">
-            <label>{{form.message.label}}
+            <label for="id_message">{{form.message.label}}
             {% if form.errors.message %}
-            <span class="red">{% trans "(this field is required)" %}</span>
-            </label>
+            <strong>{% trans "(this field is required)" %}</strong>
             {% endif %}
+            </label>
             <br/>
             {{form.message}}
         </div>
+
+        {% if form.recaptcha %}
+        <div class="form-row">
+            <label for="recaptcha_response_field">Are you a human?
+            {% if form.errors.recaptcha %}
+            <strong>{% trans "(wrong captcha)" %}</strong>
+            {% endif %}
+            </label>
+            <br/>
+            <div style="float: left;">
+            {{ form.recaptcha }}
+            </div>
+            <div class="clear"></div>
+        </div>
+        {% endif %}
+
         {{form.next}}
         <div class="submit-row">
             <input type="submit" class="submit" value="{% trans "Send Feedback" %}"/>