Ticket #14576: trac-14576.diff

File trac-14576.diff, 1.8 KB (added by steph, 5 years ago)

Patch and tests

  • django/contrib/formtools/tests/__init__.py

    diff --git a/django/contrib/formtools/tests/__init__.py b/django/contrib/formtools/tests/__init__.py
    index 9c7d46f..43e3d86 100644
    a b class WizardTests(TestCase): 
    360360                "wizard_step": "1"}
    361361        wizard(DummyRequest(POST=data))
    362362
     363    def test_14576(self):
     364        """
     365        Regression test for ticket #14576.
     366
     367        The form of the last step is not passed to the done method.
     368        """
     369        reached = [False]
     370        that = self
     371
     372        class WizardWithProcessStep(WizardClass):
     373            def done(self, request, form_list):
     374                reached[0] = True
     375                that.assertTrue(len(form_list) == 2)
     376
     377        wizard = WizardWithProcessStep([WizardPageOneForm,
     378                                        WizardPageTwoForm])
     379
     380        data = {"0-field": "test",
     381                "1-field": "test2",
     382                "hash_0": "2fdbefd4c0cad51509478fbacddf8b13",
     383                "wizard_step": "1"}
     384        wizard(DummyRequest(POST=data))
     385        self.assertTrue(reached[0])
     386
  • django/contrib/formtools/wizard.py

    diff --git a/django/contrib/formtools/wizard.py b/django/contrib/formtools/wizard.py
    index d382e29..9f1b1bd 100644
    a b class FormWizard(object): 
    132132            next_step = current_step + 1
    133133
    134134            if next_step == self.num_steps():
     135                # append the form of the current step to the form_list because
     136                # the wizard is ready to return the done view.
     137                current_form_list.append(self.get_form(current_step, request.POST))
    135138                return self.done(request, current_form_list)
    136139            else:
    137140                form = self.get_form(next_step)
Back to Top