python类RECAPTCHA_PRIVATE_KEY的实例源码

forms.py 文件源码 项目:fieldsight-kobocat 作者: awemulya 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def clean(self):
        cleaned_data = super(UserProfileFormRegister, self).clean()

        # don't check captcha if it's disabled
        if not self.REGISTRATION_REQUIRE_CAPTCHA:
            if 'recaptcha_response_field' in self._errors:
                del self._errors['recaptcha_response_field']
            return cleaned_data

        response = captcha.submit(
            cleaned_data.get('recaptcha_challenge_field'),
            cleaned_data.get('recaptcha_response_field'),
            settings.RECAPTCHA_PRIVATE_KEY,
            None)

        if not response.is_valid:
            raise forms.ValidationError(_(u"The Captcha is invalid. "
                                          u"Please, try again."))
        return cleaned_data

    # This code use to be in clean_username. Now clean_username is just
    # a convenience proxy to this method. This method is here to allow
    # the UserProfileSerializer to validate the username without reinventing
    # the wheel while still avoiding the need to instancate the form. A even
    # cleaner way would be a shared custom validator.
forms.py 文件源码 项目:FormShare 作者: qlands 项目源码 文件源码 阅读 45 收藏 0 点赞 0 评论 0
def clean(self):
        cleaned_data = super(UserProfileFormRegister, self).clean()

        # don't check captcha if it's disabled
        if not self.REGISTRATION_REQUIRE_CAPTCHA:
            if 'recaptcha_response_field' in self._errors:
                del self._errors['recaptcha_response_field']
            return cleaned_data

        response = captcha.submit(
            cleaned_data.get('recaptcha_challenge_field'),
            cleaned_data.get('recaptcha_response_field'),
            settings.RECAPTCHA_PRIVATE_KEY,
            None)

        if not response.is_valid:
            raise forms.ValidationError(_(u"The Captcha is invalid. "
                                          u"Please, try again."))
        return cleaned_data


问题


面经


文章

微信
公众号

扫码关注公众号