Fixed #17151 -- Renamed `wizard_prev_step` to the clearer `wizard_goto_step` in `NamedUrlWizardView`. Thanks, Bradley Ayers and Stephan Jaekel.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17233 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
ad5df5119f
commit
ed56e2c4a8
|
@ -12,7 +12,7 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if wizard.steps.prev %}
|
{% if wizard.steps.prev %}
|
||||||
<button name="wizard_prev_step" type="submit" value="{{ wizard.steps.first }}">{% trans "first step" %}</button>
|
<button name="wizard_goto_step" type="submit" value="{{ wizard.steps.first }}">{% trans "first step" %}</button>
|
||||||
<button name="wizard_prev_step" type="submit" value="{{ wizard.steps.prev }}">{% trans "prev step" %}</button>
|
<button name="wizard_goto_step" type="submit" value="{{ wizard.steps.prev }}">{% trans "prev step" %}</button>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<input type="submit" name="submit" value="{% trans "submit" %}" />
|
<input type="submit" name="submit" value="{% trans "submit" %}" />
|
||||||
|
|
|
@ -85,7 +85,7 @@ class NamedWizardTests(object):
|
||||||
response = self.client.post(
|
response = self.client.post(
|
||||||
reverse(self.wizard_urlname, kwargs={
|
reverse(self.wizard_urlname, kwargs={
|
||||||
'step': response.context['wizard']['steps'].current
|
'step': response.context['wizard']['steps'].current
|
||||||
}), {'wizard_prev_step': response.context['wizard']['steps'].prev})
|
}), {'wizard_goto_step': response.context['wizard']['steps'].prev})
|
||||||
response = self.client.get(response['Location'])
|
response = self.client.get(response['Location'])
|
||||||
|
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
|
@ -55,7 +55,7 @@ class WizardTests(object):
|
||||||
self.assertEqual(response.context['wizard']['steps'].current, 'form2')
|
self.assertEqual(response.context['wizard']['steps'].current, 'form2')
|
||||||
|
|
||||||
response = self.client.post(self.wizard_url, {
|
response = self.client.post(self.wizard_url, {
|
||||||
'wizard_prev_step': response.context['wizard']['steps'].prev})
|
'wizard_goto_step': response.context['wizard']['steps'].prev})
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
self.assertEqual(response.context['wizard']['steps'].current, 'form1')
|
self.assertEqual(response.context['wizard']['steps'].current, 'form1')
|
||||||
|
|
||||||
|
|
|
@ -243,12 +243,12 @@ class WizardView(TemplateView):
|
||||||
wasn't successful), the next step (if the current step was stored
|
wasn't successful), the next step (if the current step was stored
|
||||||
successful) or the done view (if no more steps are available)
|
successful) or the done view (if no more steps are available)
|
||||||
"""
|
"""
|
||||||
# Look for a wizard_prev_step element in the posted data which
|
# Look for a wizard_goto_step element in the posted data which
|
||||||
# contains a valid step name. If one was found, render the requested
|
# contains a valid step name. If one was found, render the requested
|
||||||
# form. (This makes stepping back a lot easier).
|
# form. (This makes stepping back a lot easier).
|
||||||
wizard_prev_step = self.request.POST.get('wizard_prev_step', None)
|
wizard_goto_step = self.request.POST.get('wizard_goto_step', None)
|
||||||
if wizard_prev_step and wizard_prev_step in self.get_form_list():
|
if wizard_goto_step and wizard_goto_step in self.get_form_list():
|
||||||
self.storage.current_step = wizard_prev_step
|
self.storage.current_step = wizard_goto_step
|
||||||
form = self.get_form(
|
form = self.get_form(
|
||||||
data=self.storage.get_step_data(self.steps.current),
|
data=self.storage.get_step_data(self.steps.current),
|
||||||
files=self.storage.get_step_files(self.steps.current))
|
files=self.storage.get_step_files(self.steps.current))
|
||||||
|
@ -638,10 +638,10 @@ class NamedUrlWizardView(WizardView):
|
||||||
Do a redirect if user presses the prev. step button. The rest of this
|
Do a redirect if user presses the prev. step button. The rest of this
|
||||||
is super'd from FormWizard.
|
is super'd from FormWizard.
|
||||||
"""
|
"""
|
||||||
prev_step = self.request.POST.get('wizard_prev_step', None)
|
wizard_goto_step = self.request.POST.get('wizard_goto_step', None)
|
||||||
if prev_step and prev_step in self.get_form_list():
|
if wizard_goto_step and wizard_goto_step in self.get_form_list():
|
||||||
self.storage.current_step = prev_step
|
self.storage.current_step = wizard_goto_step
|
||||||
return redirect(self.url_name, step=prev_step)
|
return redirect(self.url_name, step=wizard_goto_step)
|
||||||
return super(NamedUrlWizardView, self).post(*args, **kwargs)
|
return super(NamedUrlWizardView, self).post(*args, **kwargs)
|
||||||
|
|
||||||
def get_context_data(self, form, **kwargs):
|
def get_context_data(self, form, **kwargs):
|
||||||
|
|
|
@ -206,8 +206,8 @@ Here's a full example template:
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</table>
|
</table>
|
||||||
{% if wizard.steps.prev %}
|
{% if wizard.steps.prev %}
|
||||||
<button name="wizard_prev_step" type="submit" value="{{ wizard.steps.first }}">{% trans "first step" %}</button>
|
<button name="wizard_goto_step" type="submit" value="{{ wizard.steps.first }}">{% trans "first step" %}</button>
|
||||||
<button name="wizard_prev_step" type="submit" value="{{ wizard.steps.prev }}">{% trans "prev step" %}</button>
|
<button name="wizard_goto_step" type="submit" value="{{ wizard.steps.prev }}">{% trans "prev step" %}</button>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<input type="submit" value="{% trans "submit" %}"/>
|
<input type="submit" value="{% trans "submit" %}"/>
|
||||||
</form>
|
</form>
|
||||||
|
|
Loading…
Reference in New Issue