diff --git a/nyaa/forms.py b/nyaa/forms.py index 760988b..97c9e26 100644 --- a/nyaa/forms.py +++ b/nyaa/forms.py @@ -205,6 +205,8 @@ class CommentForm(FlaskForm): DataRequired(message='Comment must not be empty.') ]) + recaptcha = RecaptchaField(validators=[upload_recaptcha_validator_shim]) + class InlineButtonWidget(object): """ diff --git a/nyaa/templates/view.html b/nyaa/templates/view.html index 91adbda..b7466a8 100644 --- a/nyaa/templates/view.html +++ b/nyaa/templates/view.html @@ -193,8 +193,33 @@ {% if comment_form %}
{{ comment_form.csrf_token }} - {{ render_field(comment_form.comment, class_='form-control') }} - +
+
+ {{ render_field(comment_form.comment, class_='form-control') }} +
+
+ {% if config.USE_RECAPTCHA and g.user.age < config['ACCOUNT_RECAPTCHA_AGE'] %} +
+
+ {% if comment_form.recaptcha.errors %} +
+

CAPTCHA error:

+
    + {% for error in comment_form.recaptcha.errors %} +
  • {{ error }}
  • + {% endfor %} +
+
+ {% endif %} + {{ comment_form.recaptcha }} +
+
+ {% endif %} +
+
+ +
+
{% endif %}