def __call__(self, field, error=None, **kwargs):
"""Returns the recaptcha input HTML."""
if current_app.config.get('RECAPTCHA_USE_SSL', False):
server = RECAPTCHA_SSL_API_SERVER
else:
server = RECAPTCHA_API_SERVER
try:
public_key = current_app.config['RECAPTCHA_PUBLIC_KEY']
except KeyError:
raise RuntimeError("RECAPTCHA_PUBLIC_KEY config not set")
query_options = dict(k=public_key)
if field.recaptcha_error is not None:
query_options['error'] = text_type(field.recaptcha_error)
query = url_encode(query_options)
_ = field.gettext
options = {
'theme': 'clean',
'custom_translations': {
'visual_challenge': _('Get a visual challenge'),
'audio_challenge': _('Get an audio challenge'),
'refresh_btn': _('Get a new challenge'),
'instructions_visual': _('Type the two words:'),
'instructions_audio': _('Type what you hear:'),
'help_btn': _('Help'),
'play_again': _('Play sound again'),
'cant_hear_this': _('Download sound as MP3'),
'incorrect_try_again': _('Incorrect. Try again.'),
}
}
options.update(current_app.config.get('RECAPTCHA_OPTIONS', {}))
return self.recaptcha_html(server, query, options)
评论列表
文章目录