From 2ba5908f7dcc4b8396383472259ac2d85968cf4d Mon Sep 17 00:00:00 2001 From: Evgeny Fadeev Date: Sun, 24 Jul 2011 21:04:26 -0400 Subject: removed askbot settings from recaptcha django, maybe will package it later --- askbot/deps/django_authopenid/forms.py | 5 ++++- askbot/deps/recaptcha_django/__init__.py | 12 ++++++++++-- askbot/forms.py | 5 ++++- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/askbot/deps/django_authopenid/forms.py b/askbot/deps/django_authopenid/forms.py index a23f771d..065a2186 100644 --- a/askbot/deps/django_authopenid/forms.py +++ b/askbot/deps/django_authopenid/forms.py @@ -322,7 +322,10 @@ class SafeClassicRegisterForm(ClassicRegisterForm): """this form uses recaptcha in addition to the base register form """ - recaptcha = ReCaptchaField() + recaptcha = ReCaptchaField( + private_key = askbot_settings.RECAPTCHA_SECRET, + public_key = askbot_settings.RECAPTCHA_KEY + ) class ChangePasswordForm(SetPasswordForm): """ change password form """ diff --git a/askbot/deps/recaptcha_django/__init__.py b/askbot/deps/recaptcha_django/__init__.py index 518c214b..bf4c90dc 100644 --- a/askbot/deps/recaptcha_django/__init__.py +++ b/askbot/deps/recaptcha_django/__init__.py @@ -33,11 +33,15 @@ class ReCaptchaWidget(Widget): """ options = ['theme', 'lang', 'custom_theme_widget', 'tabindex'] + def __init__(self, public_key = None, *args, **kwargs): + self.public_key = public_key + super(ReCaptchaWidget, self).__init__(*args, **kwargs) + def render(self, name, value, attrs=None): final_attrs = self.build_attrs(attrs) error = final_attrs.get('error', None) html = captcha.displayhtml( - askbot_settings.RECAPTCHA_KEY, + self.public_key, error=error ) options = u',\n'.join([u'%s: "%s"' % (k, conditional_escape(v)) \ @@ -66,7 +70,11 @@ class ReCaptchaField(Field): """ Field definition for a ReCAPTCHA """ - widget = ReCaptchaWidget + + def __init__(self, private_key = None, public_key = None, *args, **kwargs): + self.widget = ReCaptchaWidget(public_key = public_key) + self.private_key = private_key + super(ReCaptchaField, self).__init__(*args, **kwargs) def clean(self, value): if value is None: diff --git a/askbot/forms.py b/askbot/forms.py index 57775ed0..446cbf83 100644 --- a/askbot/forms.py +++ b/askbot/forms.py @@ -526,7 +526,10 @@ class AdvancedSearchForm(forms.Form): return data class NotARobotForm(forms.Form): - recaptcha = ReCaptchaField() + recaptcha = ReCaptchaField( + private_key = askbot_settings.RECAPTCHA_SECRET, + public_key = askbot_settings.RECAPTCHA_KEY + ) class FeedbackForm(forms.Form): name = forms.CharField(label=_('Your name:'), required=False) -- cgit v1.2.3-1-g7c22