FormWizard does not set the step value correctly
|Reported by:||siddhi||Owned by:||anonymous|
|Severity:||Keywords:||form wizard formtools contrib|
|Cc:||join.together@…, newijk@…, v.oostveen@…, adam@…, mpjung@…, philipp@…, rokclimb15@…, bthomas@…||Triage Stage:||Accepted|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
The FormWizard class in django.contrib.formtools.wizard has a method called get_template which can be overridden to return a template for each step of the form submission process. This get_template method gets the step value as a parameter. However, no matter what step of the form processing we are in, this parameter is always 0.
The step value everywhere else is either computed dynamically or passed as a parameter. Only the get_template call uses self.step which is initialised to 0 and then never set again as we move through the steps.
The patch contains two fixes:
- The call to get_template uses the step that is passed as a parameter (and has the correct value) instead of using self.step
- self.step is updated at the end of processing
The patch also contains two test cases to check this. One of the tests should fail with the old code. Both tests should pass with the patched code.
As an aside, self.step is now used only in the repr method, so maybe it can be removed from there and then removed entirely from the FormWizard class?
Change History (22)
comment:1 Changed 9 years ago by
|Patch needs improvement:||unset|