What steps will reproduce the problem? 1. Create formwizard (from django.contrib) 2. Put captcha into one of the forms in this wizard 3. Captcha does not get validated
What is the expected output? What do you see instead? I expect captcha to pass but it never happens
What version of the product are you using? On what operating system? Version: 1.1 alpha 1 SVN-9975 latest django-simple-captcha from SVN
Please provide any additional information below. FormWizard does validation twice (after form submission and after the last step), but the record gets deleted after the 1st validation, so maybe its possible to store validation result for reuse...
Comment #1
Posted on Apr 27, 2009 by Happy CatI've never used the formwizard contrib, but will definitely give it a try and see how I can fix DSC to work with it, though.
Comment #2
Posted on Apr 27, 2009 by Happy HippoActually I'm not sure if the problem is in captcha itself. I've filed a ticket - http://code.djangoproject.com/ticket/10810 but the solution proposed is a work-around and I haven't found how to combine "one-way" fields with formwizard. It looks like conflicting requirements (revalidation in formwizard and single validation in captcha)
Comment #3
Posted on Apr 27, 2009 by Happy CatA quick-fix would probably be to comment-out the store.delete() line on line 58 of fields.py, and configure a large-enough CAPTCHA_TIMEOUT period, so that the captcha can be validated an unlimited numbed of times, during the validity period.
Comment #4
Posted on Apr 27, 2009 by Happy HippoOf course, but I don't think it's the right way to do it...
Comment #5
Posted on Feb 3, 2011 by Happy CamelMy approach was to inherit my own FormWizard class from the one provided in django.contrib.formtools.
My derived class implements its own call() method, which is basicaly cut'n'pasted from django with small difference, see following patch:
--- /tmp/modified.py 2011-02-03 01:10:20.000000000 +0100 +++ /tmp/original.py 2011-02-03 01:11:16.000000000 +0100 @@ -41,7 +41,7 @@ # must mean the validator relied on some other input, such as # an external Web site. for i, f in enumerate(final_form_list): - if not f.is_valid() and not self.has_captcha_field(f): + if not f.is_valid(): return self.render_revalidation_failure(request, i, f) return self.done(request, final_form_list)
@@ -51,4 +51,3 @@ self.step = current_step = next_step
return self.render(form, request, current_step)
the derived class also implements a static method has_captcha_field(), which looks as follows: @staticmethod def has_captcha_field(form): for f in form.fields: if type(form[f].field) == type(CaptchaField()): return True return False
it works for me pretty well.
Comment #6
Posted on Apr 1, 2011 by Happy BearMy workaround has been call "storage.delete()" at the method "delete" of the field class, this way the field can be cleaned more than once in the context of the same instance and not in multiple requests.
- fields.py 4.04KB
Status: Accepted
Labels:
Type-Enhancement
Priority-Medium