Browse files

Merge pull request #55 from Mactory/master

Recaptcha form validation
  • Loading branch information...
2 parents 2708f2c + f769e36 commit 356e7ae923a76be746f57af1cedb725f226dade3 @maccesch committed Nov 28, 2013
BIN cmsplugin_contact/locale/de/LC_MESSAGES/
Binary file not shown.
141 cmsplugin_contact/locale/de/LC_MESSAGES/django.po
@@ -3,20 +3,20 @@
# This file is distributed under the same license as the PACKAGE package.
-#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2011-07-22 15:23+0200\n"
-"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
-"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"POT-Creation-Date: 2013-11-27 16:07+0100\n"
+"PO-Revision-Date: 2013-11-27 16:07+0100\n"
+"Last-Translator: Tim Schhneider <>\n"
"Language-Team: LANGUAGE <>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
-"Plural-Forms: nplurals=2; plural=(n != 1)\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+"X-Generator: Poedit 1.5.7\n"
msgid "Akismet API Key"
@@ -58,122 +58,153 @@ msgstr ""
"Die ReCAPTCHA Bibliothek ist nicht installiert. Zum installieren: "
"\"easy_install recaptcha-client\" oder \"pip install recaptcha-client\""
+#: templates/cmsplugin_contact/subject.txt:1
msgid "Contact Form"
msgstr "Kontaktformular"
msgid "Spam Protection"
msgstr "Spamschutz"
-msgid "No subject"
-msgstr "Kein Betreff"
+msgid "Email"
+msgstr "E-Mail"
-msgid "Email recipient"
-msgstr "E-Mail Empfänger"
+msgid "Subject"
+msgstr "Betreff"
-msgid "Email sender label"
-msgstr "E-Mail Absender Beschriftung"
+msgid "Content"
+msgstr "Inhalt"
-msgid "Your email address"
-msgstr "Ihre E-Mail Adresse"
+msgid "Form name"
+msgstr "Formularname"
-msgid "Subject label"
-msgstr "Betreff Beschriftung"
+msgid "Used to distinguish multiple contact forms on the same site."
+msgstr ""
-msgid "Subject"
-msgstr "Betreff"
+msgid "Form Layout"
+msgstr ""
-msgid "Message content label"
-msgstr "Nachrichteninhalt Beschriftung"
+msgid "Choice the layout of contact form"
+msgstr ""
-msgid "Message"
-msgstr "Nachricht"
+msgid "Email recipient"
+msgstr "E-Mail Empfänger"
msgid "Thanks message"
msgstr "Dankesnachricht"
msgid "Message displayed on successful submit"
msgstr "Nachricht nach erfolgreichem Absenden"
msgid "Thank you for your message."
msgstr "Vielen Dank für Ihre Nachricht."
msgid "Submit button value"
msgstr "Senden Button Beschriftung"
msgid "Submit"
msgstr "Senden"
msgid "Spam protection method"
msgstr "Spamschutzmethode"
msgid "ReCAPTCHA theme"
msgstr "ReCAPTCHA Theme"
+msgid "default"
+msgstr ""
#: nospam/
msgid "Please don't check this box."
msgstr "Bitte nicht anklicken."
-#: nospam/
+#: nospam/
msgid "Please enter the two words on the image separated by a space:"
-msgstr "Geben Sie bitte die beiden Wörter im Bild, durch ein Leerzeichen getrennt, ein."
+msgstr ""
+"Geben Sie bitte die beiden Wörter im Bild, durch ein Leerzeichen getrennt, "
-#: nospam/
-msgid "You did not enter any of the words."
-msgstr "Sie haben keines der Wörter eingegeben."
+#: nospam/ nospam/
+msgid "Please enter the two words shown in the image."
+msgstr "Bitte geben Sie die beiden im Bild angezeigten Wörter ein."
-#: nospam/
-msgid "You did not enter the two words shown in the image."
-msgstr "Sie haben die beiden Wörter im Bild nicht eingegeben."
+#: nospam/
+msgid "An unexpected Error occurred, please try again."
+msgstr "Ein unerwarteted Fehler ist aufgetreten. Bitte versuchen Sie es erneut"
#: nospam/
-msgid "The words you entered did not match the image"
-msgstr "Die eingegebenen Wörter waren nicht richtig."
+msgid "The words you entered did not match the image. Please try again."
+msgstr ""
+"Die von Ihnen eingegebenen Wörter stimmten nicht mit dem Bild überein. Bitte "
+"versuchen Sie es erneut."
#: nospam/
msgid "Are you a robot?"
msgstr "Sind Sie ein Robot?"
-#: templates/cmsplugin_contact/contact.html:39
+#: templates/cmsplugin_contact/contact.html:24
msgid "Incorrect please try again"
msgstr "Eingabe nicht korrekt, bitte erneut versuchen"
-#: templates/cmsplugin_contact/contact.html:42
+#: templates/cmsplugin_contact/contact.html:27
msgid "Enter the words above:"
msgstr "Obige Wörter eingeben:"
-#: templates/cmsplugin_contact/contact.html:43
+#: templates/cmsplugin_contact/contact.html:28
msgid "Enter the numbers you hear:"
msgstr "Die gehörten Zahlen eingeben:"
-#: templates/cmsplugin_contact/contact.html:48
+#: templates/cmsplugin_contact/contact.html:33
msgid "Get another CAPTCHA"
msgstr "Anderes CAPTCHA"
-#: templates/cmsplugin_contact/contact.html:49
+#: templates/cmsplugin_contact/contact.html:34
msgid "Get an audio CAPTCHA"
msgstr "Audio CAPTCHA"
-#: templates/cmsplugin_contact/contact.html:50
+#: templates/cmsplugin_contact/contact.html:35
msgid "Get an image CAPTCHA"
msgstr "Bild CAPTCHA"
-#: templates/cmsplugin_contact/contact.html:52
+#: templates/cmsplugin_contact/contact.html:37
msgid "Help"
msgstr "Hilfe"
+#: templates/cmsplugin_contact/email.txt:1
+#, fuzzy
+msgid "Message from"
+msgstr "Nachricht"
+#~ msgid "No subject"
+#~ msgstr "Kein Betreff"
+#~ msgid "Email sender label"
+#~ msgstr "E-Mail Absender Beschriftung"
+#~ msgid "Your email address"
+#~ msgstr "Ihre E-Mail Adresse"
+#~ msgid "Subject label"
+#~ msgstr "Betreff Beschriftung"
+#~ msgid "Message content label"
+#~ msgstr "Nachrichteninhalt Beschriftung"
+#~ msgid "You did not enter any of the words."
+#~ msgstr "Sie haben keines der Wörter eingegeben."
36 cmsplugin_contact/nospam/
@@ -42,7 +42,7 @@ class RecaptchaForm(BaseForm):
label = _('Please enter the two words on the image separated by a space:'),
error_messages = {
'required': _('You did not enter any of the words.')
- })
+ })
recaptcha_always_validate = False
def __init__(self, *args, **kwargs):
@@ -72,31 +72,29 @@ def __init__(self, *args, **kwargs):
# Move the ReCAPTCHA fields to the end of the form
self.fields['recaptcha_challenge_field'] = self.fields.pop('recaptcha_challenge_field')
self.fields['recaptcha_response_field'] = self.fields.pop('recaptcha_response_field')
- def clean_recaptcha_response_field(self):
- if 'recaptcha_challenge_field' in self.cleaned_data:
- self._validate_captcha()
- return self.cleaned_data['recaptcha_response_field']
- def clean_recaptcha_challenge_field(self):
- if 'recaptcha_response_field' in self.cleaned_data:
- self._validate_captcha()
- return self.cleaned_data['recaptcha_challenge_field']
- def _validate_captcha(self):
+ # since we depend on two fields, we should clean the captcha in the clean method
+ def clean(self):
+ cd = self.cleaned_data
if not self.recaptcha_always_validate:
- rcf = self.cleaned_data['recaptcha_challenge_field']
- rrf = self.cleaned_data['recaptcha_response_field']
- if rrf == '':
- raise forms.ValidationError(_('You did not enter the two words shown in the image.'))
+ if not (bool(cd.get('recaptcha_response_field')) & bool(cd.get('recaptcha_challenge_field'))):
+ if not cd.get('recaptcha_challenge_field'):
+ self._errors['recaptcha_challenge_field'] = self.error_class([_('An unexpected Error occurred, please try again.')])
+ if not cd.get('recaptcha_response_field'):
+ self._errors['recaptcha_response_field'] = self.error_class([_('Please enter the two words shown in the image.')])
+ rcf = self.cleaned_data['recaptcha_challenge_field']
+ rrf = self.cleaned_data['recaptcha_response_field']
from recaptcha.client import captcha as recaptcha
ip = self._request.META['REMOTE_ADDR']
check = recaptcha.submit(rcf, rrf, self._recaptcha_private_key, ip)
if not check.is_valid:
- raise forms.ValidationError(_('The words you entered did not match the image.'))
+ self._errors['recaptcha_response_field'] = self.error_class([_('The words you entered did not match the image. Please try again.')])
+ del cd['recaptcha_response_field']
+ return cd
class HoneyPotForm(BaseForm):
accept_terms = HoneypotField()

0 comments on commit 356e7ae

Please sign in to comment.