From 3595a8e2201ccabf7150f479e2dfd433b1b8cb79 Mon Sep 17 00:00:00 2001 From: Antoine Goutenoir Date: Thu, 27 May 2021 08:31:37 +0200 Subject: [PATCH] fix: disable the captcha --- flaskr/__init__.py | 5 +++-- flaskr/forms.py | 29 ++++++++++++++--------------- flaskr/templates/estimation-request.html | 48 ++++++++++++++++++++++++------------------------ 3 files changed, 41 insertions(+), 41 deletions(-) diff --git a/flaskr/__init__.py b/flaskr/__init__.py index 913ae3a..c79e5fb 100755 --- a/flaskr/__init__.py +++ b/flaskr/__init__.py @@ -1,8 +1,9 @@ #! ../venv/bin/python import os -from markdown import markdown from dotenv import load_dotenv, find_dotenv, dotenv_values +from markdown import markdown + # Load config from .env ; do this before importing local libs (and flask) # 1. Write into OS environment -- if this fails you forgot to create .env file load_dotenv(find_dotenv(raise_error_if_not_found=True), override=True) @@ -63,7 +64,7 @@ def create_app(object_name): app.config['BASIC_AUTH_USERNAME'] = os.getenv('ADMIN_USERNAME') app.config['BASIC_AUTH_PASSWORD'] = os.getenv('ADMIN_PASSWORD') - app.config['CAPTCHA_ENABLE'] = True + app.config['CAPTCHA_ENABLE'] = False app.config['CAPTCHA_LENGTH'] = 5 app.config['CAPTCHA_WIDTH'] = 256 app.config['CAPTCHA_HEIGHT'] = 158 diff --git a/flaskr/forms.py b/flaskr/forms.py index 9b0e5ab..06d787e 100644 --- a/flaskr/forms.py +++ b/flaskr/forms.py @@ -11,7 +11,6 @@ from wtforms import validators from .content import content_dict as content from .core import models -from .extensions import captcha from .models import User form_content = content['estimate']['form'] @@ -134,14 +133,14 @@ class EstimateForm(FlaskForm): # ) ], ) - captcha = StringField( - label=form_content['captcha']['label'], - description=form_content['captcha']['description'], - validators=[ - validators.InputRequired(), - validators.Length(max=16), - ], - ) + # captcha = StringField( + # label=form_content['captcha']['label'], + # description=form_content['captcha']['description'], + # validators=[ + # validators.InputRequired(), + # validators.Length(max=16), + # ], + # ) upload_set = ['csv', 'xls', 'xlsx'] @@ -169,12 +168,12 @@ class EstimateForm(FlaskForm): if not check_validate: return False - if self.captcha.data != IS_HUMAN: - if not captcha.validate(): - self.captcha.errors.append( - "Captcha do not match. Try again." - ) - return False + # if self.captcha.data != IS_HUMAN: + # if not captcha.validate(): + # self.captcha.errors.append( + # "Captcha do not match. Try again." + # ) + # return False # Origins must be set either by field or file if ( diff --git a/flaskr/templates/estimation-request.html b/flaskr/templates/estimation-request.html index 8812a37..9fd91b1 100644 --- a/flaskr/templates/estimation-request.html +++ b/flaskr/templates/estimation-request.html @@ -176,30 +176,30 @@ {{ content.estimate.help.run_name | safe }} -
-
- {{ form.captcha.label }} - * -
-
- {{ captcha() }} -

- - {{ form.captcha( - title=form.captcha.description, - class_="form-control", - placeholder="Please write the numbers you see in the image above." - ) | safe }} - - {% if form.captcha.errors -%} -
    - {% for error in form.captcha.errors %} -
  • {{ error }}
  • - {% endfor %} -
- {%- endif %} -
-
+{#
#} +{#
#} +{# {{ form.captcha.label }}#} +{# *#} +{#
#} +{#
#} +{# {{ captcha() }}#} +{#

#} +{##} +{# {{ form.captcha(#} +{# title=form.captcha.description,#} +{# class_="form-control",#} +{# placeholder="Please write the numbers you see in the image above."#} +{# ) | safe }}#} +{##} +{# {% if form.captcha.errors -%}#} +{#
    #} +{# {% for error in form.captcha.errors %}#} +{#
  • {{ error }}
  • #} +{# {% endfor %}#} +{#
#} +{# {%- endif %}#} +{#
#} +{#
#}