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
View
BIN cmsplugin_contact/locale/de/LC_MESSAGES/django.mo
Binary file not shown.
View
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.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
-#, 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 <tim.schneider@northbridge-development.de>\n"
"Language-Team: LANGUAGE <LL@li.org>\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"
#: admin.py:16
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\""
-#: cms_plugins.py:17
+#: cms_plugins.py:29 templates/cmsplugin_contact/subject.txt:1
msgid "Contact Form"
msgstr "Kontaktformular"
-#: cms_plugins.py:25
+#: cms_plugins.py:39
msgid "Spam Protection"
msgstr "Spamschutz"
-#: cms_plugins.py:84
-msgid "No subject"
-msgstr "Kein Betreff"
+#: forms.py:7
+msgid "Email"
+msgstr "E-Mail"
-#: models.py:20
-msgid "Email recipient"
-msgstr "E-Mail Empfänger"
+#: forms.py:8
+msgid "Subject"
+msgstr "Betreff"
-#: models.py:21
-msgid "Email sender label"
-msgstr "E-Mail Absender Beschriftung"
+#: forms.py:9
+msgid "Content"
+msgstr "Inhalt"
-#: models.py:21
-msgid "Your email address"
-msgstr "Ihre E-Mail Adresse"
+#: models.py:24
+msgid "Form name"
+msgstr "Formularname"
-#: models.py:22
-msgid "Subject label"
-msgstr "Betreff Beschriftung"
+#: models.py:27
+msgid "Used to distinguish multiple contact forms on the same site."
+msgstr ""
-#: models.py:22
-msgid "Subject"
-msgstr "Betreff"
+#: models.py:28
+msgid "Form Layout"
+msgstr ""
-#: models.py:23
-msgid "Message content label"
-msgstr "Nachrichteninhalt Beschriftung"
+#: models.py:30
+msgid "Choice the layout of contact form"
+msgstr ""
-#: models.py:23
-msgid "Message"
-msgstr "Nachricht"
+#: models.py:33
+msgid "Email recipient"
+msgstr "E-Mail Empfänger"
-#: models.py:24
+#: models.py:36
msgid "Thanks message"
msgstr "Dankesnachricht"
-#: models.py:24
+#: models.py:37
msgid "Message displayed on successful submit"
msgstr "Nachricht nach erfolgreichem Absenden"
-#: models.py:24
+#: models.py:38
msgid "Thank you for your message."
msgstr "Vielen Dank für Ihre Nachricht."
-#: models.py:25
+#: models.py:39
msgid "Submit button value"
msgstr "Senden Button Beschriftung"
-#: models.py:25
+#: models.py:40
msgid "Submit"
msgstr "Senden"
-#: models.py:27
+#: models.py:43
msgid "Spam protection method"
msgstr "Spamschutzmethode"
-#: models.py:33
+#: models.py:53
msgid "ReCAPTCHA theme"
msgstr "ReCAPTCHA Theme"
+#: settings.py:7
+msgid "default"
+msgstr ""
+
#: nospam/fields.py:13
msgid "Please don't check this box."
msgstr "Bitte nicht anklicken."
-#: nospam/forms.py:42
+#: nospam/forms.py:46
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, "
+"ein."
-#: nospam/forms.py:44
-msgid "You did not enter any of the words."
-msgstr "Sie haben keines der Wörter eingegeben."
+#: nospam/forms.py:48 nospam/forms.py:90
+msgid "Please enter the two words shown in the image."
+msgstr "Bitte geben Sie die beiden im Bild angezeigten Wörter ein."
-#: nospam/forms.py:92
-msgid "You did not enter the two words shown in the image."
-msgstr "Sie haben die beiden Wörter im Bild nicht eingegeben."
+#: nospam/forms.py:88
+msgid "An unexpected Error occurred, please try again."
+msgstr "Ein unerwarteted Fehler ist aufgetreten. Bitte versuchen Sie es erneut"
#: nospam/forms.py:98
-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/widgets.py:30
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."
View
36 cmsplugin_contact/nospam/forms.py
@@ -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.')])
else:
+ 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.