Form Wizard and captcha

121 views
Skip to first unread message

qrilka

unread,
Apr 8, 2009, 2:29:12 PM4/8/09
to Django users
I've stumbled upon from revalidation in form wizard. The similar
problem was discussed a year ago -
http://groups.google.com/group/django-users/browse_thread/thread/a6fdf2971f96deed/6313eb5a18a40085
I have somewhat different problem: on the last of my forms I use
captcha field, but after successful validation the test string for it
gets erased (either in cache in supercaptcha or in DB in django-simple-
captcha) and its quite normal from my point of view. But form wizard
does form revalidation at the end so I get validation error.
The only solution I see now (except from not using from wizard) is to
hack captcha field and not to delete test string after success.But
this option lokks somewhat nasty to me.
Maybe there are some other ways around?

Best regards,
Kirill.

Kirill Zaborski

unread,
Apr 13, 2009, 3:43:03 PM4/13/09
to django...@googlegroups.com
So no answers were given and I tried to fix FormWizard class.
The patch is attached and the only thing changed is that the revalidation is made with forms which  were before the last one (I do not see any reason for the second validation of it).
Is there any chance to get it into the trunk?
Do I need to make any additional steps for this to happen?

Kirill.


On 8 апр, 22:29, qrilka <qri...@gmail.com> wrote:
> I've stumbled upon from revalidation in form wizard. The similar
> problem was discussed a year ago -http://groups.google.com/group/django-users/browse_thread/thread/a6fd...
wizard_revalidation.diff

Adi Sieker

unread,
Apr 13, 2009, 4:14:40 PM4/13/09
to django...@googlegroups.com
On 13.04.2009, at 21:43, Kirill Zaborski wrote:

So no answers were given and I tried to fix FormWizard class.
The patch is attached and the only thing changed is that the revalidation is made with forms which  were before the last one (I do not see any reason for the second validation of it).
Is there any chance to get it into the trunk?
Do I need to make any additional steps for this to happen?

open a ticket on code.djangoproject.com/simpleticket attach the patch and see what the devs think of it.

adi


Kirill.

On 8 апр, 22:29, qrilka <qri...@gmail.com> wrote:
> I've stumbled upon from revalidation in form wizard. The similar
> problem was discussed a year ago -http://groups.google.com/group/django-users/browse_thread/thread/a6fd...
> I have somewhat different problem: on the last of my forms I use
> captcha field, but after successful validation the test string for it
> gets erased (either in cache in supercaptcha or in DB in django-simple-
> captcha) and its quite normal from my point of view. But form wizard
> does form revalidation at the end so I get validation error.
> The only solution I see now (except from not using from wizard) is to
> hack captcha field and not to delete test string after success.But
> this option lokks somewhat nasty to me.
> Maybe there are some other ways around?
>
> Best regards,Kirill.



Index: django/contrib/formtools/wizard.py
===================================================================
--- django/contrib/formtools/wizard.py (revision 9975)
+++ django/contrib/formtools/wizard.py (working copy)
@@ -76,19 +76,19 @@
            self.process_step(request, form, current_step)
            next_step = current_step + 1

-            # If this was the last step, validate all of the forms one more
+            # If this was the last step, validate all of the previous forms one more
            # time, as a sanity check, and call done().
            num = self.num_steps()
            if next_step == num:
-                final_form_list = [self.get_form(i, request.POST) for i in range(num)]
+                prior_form_list = [self.get_form(i, request.POST) for i in range(num - 1)]

                # Validate all the forms. If any of them fail validation, that
                # must mean the validator relied on some other input, such as
                # an external Web site.
-                for i, f in enumerate(final_form_list):
+                for i, f in enumerate(prior_form_list):
                    if not f.is_valid():
                        return self.render_revalidation_failure(request, i, f)
-                return self.done(request, final_form_list)
+                return self.done(request, prior_form_list+[form])

            # Otherwise, move along to the next step.
            else:

qrilka

unread,
Apr 13, 2009, 4:41:17 PM4/13/09
to Django users
Thanks, will do that tomorrow.

Kirill.
Reply all
Reply to author
Forward
0 new messages