Merge pull request #942 from stephrdev/trac-18000
Fixed #18000 -- Moved the code to handle goto requests to an extra WizardView method.
This commit is contained in:
commit
e7514e4978
|
@ -265,11 +265,7 @@ class WizardView(TemplateView):
|
||||||
# form. (This makes stepping back a lot easier).
|
# form. (This makes stepping back a lot easier).
|
||||||
wizard_goto_step = self.request.POST.get('wizard_goto_step', None)
|
wizard_goto_step = self.request.POST.get('wizard_goto_step', None)
|
||||||
if wizard_goto_step and wizard_goto_step in self.get_form_list():
|
if wizard_goto_step and wizard_goto_step in self.get_form_list():
|
||||||
self.storage.current_step = wizard_goto_step
|
return self.render_goto_step(wizard_goto_step)
|
||||||
form = self.get_form(
|
|
||||||
data=self.storage.get_step_data(self.steps.current),
|
|
||||||
files=self.storage.get_step_files(self.steps.current))
|
|
||||||
return self.render(form)
|
|
||||||
|
|
||||||
# Check if form was refreshed
|
# Check if form was refreshed
|
||||||
management_form = ManagementForm(self.request.POST, prefix=self.prefix)
|
management_form = ManagementForm(self.request.POST, prefix=self.prefix)
|
||||||
|
@ -317,6 +313,17 @@ class WizardView(TemplateView):
|
||||||
self.storage.current_step = next_step
|
self.storage.current_step = next_step
|
||||||
return self.render(new_form, **kwargs)
|
return self.render(new_form, **kwargs)
|
||||||
|
|
||||||
|
def render_goto_step(self, goto_step, **kwargs):
|
||||||
|
"""
|
||||||
|
This method gets called when the current step has to be changed.
|
||||||
|
`goto_step` contains the requested step to go to.
|
||||||
|
"""
|
||||||
|
self.storage.current_step = goto_step
|
||||||
|
form = self.get_form(
|
||||||
|
data=self.storage.get_step_data(self.steps.current),
|
||||||
|
files=self.storage.get_step_files(self.steps.current))
|
||||||
|
return self.render(form)
|
||||||
|
|
||||||
def render_done(self, form, **kwargs):
|
def render_done(self, form, **kwargs):
|
||||||
"""
|
"""
|
||||||
This method gets called when all forms passed. The method should also
|
This method gets called when all forms passed. The method should also
|
||||||
|
@ -660,8 +667,7 @@ class NamedUrlWizardView(WizardView):
|
||||||
"""
|
"""
|
||||||
wizard_goto_step = self.request.POST.get('wizard_goto_step', None)
|
wizard_goto_step = self.request.POST.get('wizard_goto_step', None)
|
||||||
if wizard_goto_step and wizard_goto_step in self.get_form_list():
|
if wizard_goto_step and wizard_goto_step in self.get_form_list():
|
||||||
self.storage.current_step = wizard_goto_step
|
return self.render_goto_step(wizard_goto_step)
|
||||||
return redirect(self.get_step_url(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):
|
||||||
|
@ -682,6 +688,14 @@ class NamedUrlWizardView(WizardView):
|
||||||
self.storage.current_step = next_step
|
self.storage.current_step = next_step
|
||||||
return redirect(self.get_step_url(next_step))
|
return redirect(self.get_step_url(next_step))
|
||||||
|
|
||||||
|
def render_goto_step(self, goto_step, **kwargs):
|
||||||
|
"""
|
||||||
|
This method gets called when the current step has to be changed.
|
||||||
|
`goto_step` contains the requested step to go to.
|
||||||
|
"""
|
||||||
|
self.storage.current_step = goto_step
|
||||||
|
return redirect(self.get_step_url(goto_step))
|
||||||
|
|
||||||
def render_revalidation_failure(self, failed_step, form, **kwargs):
|
def render_revalidation_failure(self, failed_step, form, **kwargs):
|
||||||
"""
|
"""
|
||||||
When a step fails, we have to redirect the user to the first failing
|
When a step fails, we have to redirect the user to the first failing
|
||||||
|
|
|
@ -469,6 +469,17 @@ Advanced ``WizardView`` methods
|
||||||
def process_step_files(self, form):
|
def process_step_files(self, form):
|
||||||
return self.get_form_step_files(form)
|
return self.get_form_step_files(form)
|
||||||
|
|
||||||
|
.. method:: WizardView.render_goto_step(step, goto_step, **kwargs)
|
||||||
|
|
||||||
|
.. versionadded:: 1.6
|
||||||
|
|
||||||
|
This method is called when the step should be changed to something else
|
||||||
|
than the next step. By default, this method just stores the requested
|
||||||
|
step ``goto_step`` in the storage and then renders the new step.
|
||||||
|
|
||||||
|
If you want to store the entered data of the current step before rendering
|
||||||
|
the next step, you can overwrite this method.
|
||||||
|
|
||||||
.. method:: WizardView.render_revalidation_failure(step, form, **kwargs)
|
.. method:: WizardView.render_revalidation_failure(step, form, **kwargs)
|
||||||
|
|
||||||
When the wizard thinks all steps have passed it revalidates all forms with
|
When the wizard thinks all steps have passed it revalidates all forms with
|
||||||
|
|
Loading…
Reference in New Issue