Commit f9c4d6c0a13eff7bf1be453128f7a4b244de4e06

Authored by Antoine Goutenoir
1 parent b777efad
Exists in master

fix: disable the captcha

flaskr/__init__.py
1 #! ../venv/bin/python 1 #! ../venv/bin/python
2 import os 2 import os
3 -from markdown import markdown  
4 3
5 from dotenv import load_dotenv, find_dotenv, dotenv_values 4 from dotenv import load_dotenv, find_dotenv, dotenv_values
  5 +from markdown import markdown
  6 +
6 # Load config from .env ; do this before importing local libs (and flask) 7 # Load config from .env ; do this before importing local libs (and flask)
7 # 1. Write into OS environment -- if this fails you forgot to create .env file 8 # 1. Write into OS environment -- if this fails you forgot to create .env file
8 load_dotenv(find_dotenv(raise_error_if_not_found=True), override=True) 9 load_dotenv(find_dotenv(raise_error_if_not_found=True), override=True)
@@ -63,7 +64,7 @@ def create_app(object_name): @@ -63,7 +64,7 @@ def create_app(object_name):
63 app.config['BASIC_AUTH_USERNAME'] = os.getenv('ADMIN_USERNAME') 64 app.config['BASIC_AUTH_USERNAME'] = os.getenv('ADMIN_USERNAME')
64 app.config['BASIC_AUTH_PASSWORD'] = os.getenv('ADMIN_PASSWORD') 65 app.config['BASIC_AUTH_PASSWORD'] = os.getenv('ADMIN_PASSWORD')
65 66
66 - app.config['CAPTCHA_ENABLE'] = True 67 + app.config['CAPTCHA_ENABLE'] = False
67 app.config['CAPTCHA_LENGTH'] = 5 68 app.config['CAPTCHA_LENGTH'] = 5
68 app.config['CAPTCHA_WIDTH'] = 256 69 app.config['CAPTCHA_WIDTH'] = 256
69 app.config['CAPTCHA_HEIGHT'] = 158 70 app.config['CAPTCHA_HEIGHT'] = 158
flaskr/forms.py
@@ -11,7 +11,6 @@ from wtforms import validators @@ -11,7 +11,6 @@ from wtforms import validators
11 11
12 from .content import content_dict as content 12 from .content import content_dict as content
13 from .core import models 13 from .core import models
14 -from .extensions import captcha  
15 from .models import User 14 from .models import User
16 15
17 form_content = content['estimate']['form'] 16 form_content = content['estimate']['form']
@@ -134,14 +133,14 @@ class EstimateForm(FlaskForm): @@ -134,14 +133,14 @@ class EstimateForm(FlaskForm):
134 # ) 133 # )
135 ], 134 ],
136 ) 135 )
137 - captcha = StringField(  
138 - label=form_content['captcha']['label'],  
139 - description=form_content['captcha']['description'],  
140 - validators=[  
141 - validators.InputRequired(),  
142 - validators.Length(max=16),  
143 - ],  
144 - ) 136 + # captcha = StringField(
  137 + # label=form_content['captcha']['label'],
  138 + # description=form_content['captcha']['description'],
  139 + # validators=[
  140 + # validators.InputRequired(),
  141 + # validators.Length(max=16),
  142 + # ],
  143 + # )
145 144
146 upload_set = ['csv', 'xls', 'xlsx'] 145 upload_set = ['csv', 'xls', 'xlsx']
147 146
@@ -169,12 +168,12 @@ class EstimateForm(FlaskForm): @@ -169,12 +168,12 @@ class EstimateForm(FlaskForm):
169 if not check_validate: 168 if not check_validate:
170 return False 169 return False
171 170
172 - if self.captcha.data != IS_HUMAN:  
173 - if not captcha.validate():  
174 - self.captcha.errors.append(  
175 - "Captcha do not match. Try again."  
176 - )  
177 - return False 171 + # if self.captcha.data != IS_HUMAN:
  172 + # if not captcha.validate():
  173 + # self.captcha.errors.append(
  174 + # "Captcha do not match. Try again."
  175 + # )
  176 + # return False
178 177
179 # Origins must be set either by field or file 178 # Origins must be set either by field or file
180 if ( 179 if (
flaskr/templates/estimation-request.html
@@ -176,30 +176,30 @@ @@ -176,30 +176,30 @@
176 <small class="form-text text-muted">{{ content.estimate.help.run_name | safe }}</small> 176 <small class="form-text text-muted">{{ content.estimate.help.run_name | safe }}</small>
177 </div> 177 </div>
178 178
179 - <div class="form-group">  
180 - <dt>  
181 - {{ form.captcha.label }}  
182 - <span class="required-asterisk" title="This field is required.">*</span>  
183 - </dt>  
184 - <dd>  
185 - {{ captcha() }}  
186 - <br><br>  
187 -  
188 - {{ form.captcha(  
189 - title=form.captcha.description,  
190 - class_="form-control",  
191 - placeholder="Please write the numbers you see in the image above."  
192 - ) | safe }}  
193 -  
194 - {% if form.captcha.errors -%}  
195 - <ul class="errors text-danger has-error">  
196 - {% for error in form.captcha.errors %}  
197 - <li>{{ error }}</li>  
198 - {% endfor %}  
199 - </ul>  
200 - {%- endif %}  
201 - </dd>  
202 - </div> 179 +{# <div class="form-group">#}
  180 +{# <dt>#}
  181 +{# {{ form.captcha.label }}#}
  182 +{# <span class="required-asterisk" title="This field is required.">*</span>#}
  183 +{# </dt>#}
  184 +{# <dd>#}
  185 +{# {{ captcha() }}#}
  186 +{# <br><br>#}
  187 +{##}
  188 +{# {{ form.captcha(#}
  189 +{# title=form.captcha.description,#}
  190 +{# class_="form-control",#}
  191 +{# placeholder="Please write the numbers you see in the image above."#}
  192 +{# ) | safe }}#}
  193 +{##}
  194 +{# {% if form.captcha.errors -%}#}
  195 +{# <ul class="errors text-danger has-error">#}
  196 +{# {% for error in form.captcha.errors %}#}
  197 +{# <li>{{ error }}</li>#}
  198 +{# {% endfor %}#}
  199 +{# </ul>#}
  200 +{# {%- endif %}#}
  201 +{# </dd>#}
  202 +{# </div>#}
203 203
204 <button type="submit" class="btn btn-primary"> 204 <button type="submit" class="btn btn-primary">
205 Submit a Request 205 Submit a Request