Ticket #17151: trac-17151.diff

File trac-17151.diff, 5.4 KB (added by steph, 4 years ago)

Patch with goto instead of prev

  • django/contrib/formtools/templates/formtools/wizard/wizard_form.html

    diff --git a/django/contrib/formtools/templates/formtools/wizard/wizard_form.html b/django/contrib/formtools/templates/formtools/wizard/wizard_form.html
    index fe75522..95bc576 100644
    a b  
    1212{% endif %}
    1313
    1414{% if wizard.steps.prev %}
    15 <button name="wizard_prev_step" type="submit" value="{{ wizard.steps.first }}">{% trans "first step" %}</button>
    16 <button name="wizard_prev_step" type="submit" value="{{ wizard.steps.prev }}">{% trans "prev step" %}</button>
     15<button name="wizard_goto_step" type="submit" value="{{ wizard.steps.first }}">{% trans "first step" %}</button>
     16<button name="wizard_goto_step" type="submit" value="{{ wizard.steps.prev }}">{% trans "prev step" %}</button>
    1717{% endif %}
    1818<input type="submit" name="submit" value="{% trans "submit" %}" />
  • django/contrib/formtools/tests/wizard/namedwizardtests/tests.py

    diff --git a/django/contrib/formtools/tests/wizard/namedwizardtests/tests.py b/django/contrib/formtools/tests/wizard/namedwizardtests/tests.py
    index 0f63882..e4ec80e 100644
    a b class NamedWizardTests(object): 
    8383        response = self.client.post(
    8484            reverse(self.wizard_urlname, kwargs={
    8585                'step': response.context['wizard']['steps'].current
    86             }), {'wizard_prev_step': response.context['wizard']['steps'].prev})
     86            }), {'wizard_goto_step': response.context['wizard']['steps'].prev})
    8787        response = self.client.get(response['Location'])
    8888
    8989        self.assertEqual(response.status_code, 200)
  • django/contrib/formtools/tests/wizard/wizardtests/tests.py

    diff --git a/django/contrib/formtools/tests/wizard/wizardtests/tests.py b/django/contrib/formtools/tests/wizard/wizardtests/tests.py
    index 9868721..1d325fd 100644
    a b class WizardTests(object): 
    5252        self.assertEqual(response.context['wizard']['steps'].current, 'form2')
    5353
    5454        response = self.client.post(self.wizard_url, {
    55             'wizard_prev_step': response.context['wizard']['steps'].prev})
     55            'wizard_goto_step': response.context['wizard']['steps'].prev})
    5656        self.assertEqual(response.status_code, 200)
    5757        self.assertEqual(response.context['wizard']['steps'].current, 'form1')
    5858
  • django/contrib/formtools/wizard/views.py

    diff --git a/django/contrib/formtools/wizard/views.py b/django/contrib/formtools/wizard/views.py
    index 15ba146..940e95c 100644
    a b class WizardView(TemplateView): 
    243243        wasn't successful), the next step (if the current step was stored
    244244        successful) or the done view (if no more steps are available)
    245245        """
    246         # Look for a wizard_prev_step element in the posted data which
     246        # Look for a wizard_goto_step element in the posted data which
    247247        # contains a valid step name. If one was found, render the requested
    248248        # form. (This makes stepping back a lot easier).
    249         wizard_prev_step = self.request.POST.get('wizard_prev_step', None)
    250         if wizard_prev_step and wizard_prev_step in self.get_form_list():
    251             self.storage.current_step = wizard_prev_step
     249        wizard_goto_step = self.request.POST.get('wizard_goto_step', None)
     250        if wizard_goto_step and wizard_goto_step in self.get_form_list():
     251            self.storage.current_step = wizard_goto_step
    252252            form = self.get_form(
    253253                data=self.storage.get_step_data(self.steps.current),
    254254                files=self.storage.get_step_files(self.steps.current))
    class NamedUrlWizardView(WizardView): 
    638638        Do a redirect if user presses the prev. step button. The rest of this
    639639        is super'd from FormWizard.
    640640        """
    641         prev_step = self.request.POST.get('wizard_prev_step', None)
    642         if prev_step and prev_step in self.get_form_list():
    643             self.storage.current_step = prev_step
    644             return redirect(self.url_name, step=prev_step)
     641        wizard_goto_step = self.request.POST.get('wizard_goto_step', None)
     642        if wizard_goto_step and wizard_goto_step in self.get_form_list():
     643            self.storage.current_step = wizard_goto_step
     644            return redirect(self.url_name, step=wizard_goto_step)
    645645        return super(NamedUrlWizardView, self).post(*args, **kwargs)
    646646
    647647    def render_next_step(self, form, **kwargs):
  • docs/ref/contrib/formtools/form-wizard.txt

    diff --git a/docs/ref/contrib/formtools/form-wizard.txt b/docs/ref/contrib/formtools/form-wizard.txt
    index aadd7d2..197d04b 100644
    a b Here's a full example template: 
    206206    {% endif %}
    207207    </table>
    208208    {% if wizard.steps.prev %}
    209     <button name="wizard_prev_step" type="submit" value="{{ wizard.steps.first }}">{% trans "first step" %}</button>
    210     <button name="wizard_prev_step" type="submit" value="{{ wizard.steps.prev }}">{% trans "prev step" %}</button>
     209    <button name="wizard_goto_step" type="submit" value="{{ wizard.steps.first }}">{% trans "first step" %}</button>
     210    <button name="wizard_goto_step" type="submit" value="{{ wizard.steps.prev }}">{% trans "prev step" %}</button>
    211211    {% endif %}
    212212    <input type="submit" value="{% trans "submit" %}"/>
    213213    </form>
Back to Top