commenting: show CAPTCHA to new accounts (#443)

Basically re-use the upload CAPTCHA code to also do this for
comments.
This commit is contained in:
Nicolas F 2018-02-01 19:50:00 +01:00 committed by Arylide
parent f8a287caa0
commit 0285c12264
2 changed files with 29 additions and 2 deletions

View File

@ -205,6 +205,8 @@ class CommentForm(FlaskForm):
DataRequired(message='Comment must not be empty.')
])
recaptcha = RecaptchaField(validators=[upload_recaptcha_validator_shim])
class InlineButtonWidget(object):
"""

View File

@ -193,8 +193,33 @@
{% if comment_form %}
<form class="comment-box" method="POST">
{{ comment_form.csrf_token }}
{{ render_field(comment_form.comment, class_='form-control') }}
<input type="submit" value="Submit" class="btn btn-success btn-sm">
<div class="row">
<div class="col-md-12">
{{ render_field(comment_form.comment, class_='form-control') }}
</div>
</div>
{% if config.USE_RECAPTCHA and g.user.age < config['ACCOUNT_RECAPTCHA_AGE'] %}
<div class="row">
<div class="col-md-4">
{% if comment_form.recaptcha.errors %}
<div class="alert alert-danger">
<p><strong>CAPTCHA error:</strong></p>
<ul>
{% for error in comment_form.recaptcha.errors %}
<li>{{ error }}</li>
{% endfor %}
</ul>
</div>
{% endif %}
{{ comment_form.recaptcha }}
</div>
</div>
{% endif %}
<div class="row">
<div class="col-md-12">
<input type="submit" value="Submit" class="btn btn-success btn-sm">
</div>
</div>
</form>
{% endif %}
</div>