Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Don't display captcha and ratelimit fields when they aren't needed.

  • Loading branch information...
commit 2248c4a2f3dc7e2db1f1268f6368a71f4766a760 1 parent 766dd00
Bryce Boe bboe authored spladug committed

Showing 1 changed file with 9 additions and 12 deletions. Show diff stats Hide diff stats

  1. +9 12 r2/r2/controllers/validator/validator.py
21 r2/r2/controllers/validator/validator.py
@@ -237,21 +237,18 @@ def validatedForm(self, self_method, responder, simple_vals, param_vals,
237 237 # clear out the status line as a courtesy
238 238 form.set_html(".status", "")
239 239
240   - # handle specific errors
241   - if c.errors.errors:
242   - handled_captcha = handled_ratelimit = False
243   - for v in simple_vals:
244   - if not handled_captcha and isinstance(v, VCaptcha):
245   - form.has_errors('captcha', errors.BAD_CAPTCHA)
246   - form.new_captcha()
247   - handled_captcha = True
248   - elif not handled_ratelimit and isinstance(v, VRatelimit):
249   - form.ratelimit(v.seconds)
250   - handled_ratelimit = True
251   -
252 240 # do the actual work
253 241 val = self_method(self, form, responder, *a, **kw)
254 242
  243 + # add data to the output on some errors
  244 + for validator in simple_vals:
  245 + if (isinstance(validator, VCaptcha) and
  246 + form.has_errors('captcha', errors.BAD_CAPTCHA)):
  247 + form.new_captcha()
  248 + elif (isinstance(validator, VRatelimit) and
  249 + form.has_errors('ratelimit', errors.RATELIMIT)):
  250 + form.ratelimit(validator.seconds)
  251 +
255 252 if val:
256 253 return val
257 254 else:

0 comments on commit 2248c4a

Please sign in to comment.
Something went wrong with that request. Please try again.