def render_revalidation_failure(self, failed_step, form, **kwargs):
     """
     When a step fails, we have to redirect the user to the first failing
     step.
     """
     self.storage.current_step = failed_step
     return redirect(self.get_step_url(failed_step))
    def get(self, *args, **kwargs):
        """
        This renders the form or, if needed, does the http redirects.
        """
        step_url = kwargs.get('step', None)
        if step_url is None:
            if 'reset' in self.request.GET:
                self.storage.reset()
                self.storage.current_step = self.steps.first
            if self.request.GET:
                query_string = "?%s" % self.request.GET.urlencode()
            else:
                query_string = ""
            return redirect(
                self.get_step_url(self.steps.current) + query_string)

        # is the current step the "done" name/view?
        elif step_url == self.done_step_name:
            last_step = self.steps.last
            return self.render_done(
                self.get_form(step=last_step,
                              data=self.storage.get_step_data(last_step),
                              files=self.storage.get_step_files(last_step)),
                **kwargs)

        # is the url step name not equal to the step in the storage?
        # if yes, change the step in the storage (if name exists)
        elif step_url == self.steps.current:
            # URL step name and storage step name are equal, render!
            return self.render(
                self.get_form(
                    data=self.storage.current_step_data,
                    files=self.storage.current_step_files,
                ), **kwargs)

        elif step_url in self.get_form_list():
            self.storage.current_step = step_url
            return self.render(
                self.get_form(
                    data=self.storage.current_step_data,
                    files=self.storage.current_step_files,
                ), **kwargs)

        # invalid step name, reset to first and redirect.
        else:
            self.storage.current_step = self.steps.first
            return redirect(self.get_step_url(self.steps.first))
 def render_done(self, form, **kwargs):
     """
     When rendering the done view, we have to redirect first (if the URL
     name doesn't fit).
     """
     if kwargs.get('step', None) != self.done_step_name:
         return redirect(self.get_step_url(self.done_step_name))
     return super(NamedUrlWizardView, self).render_done(form, **kwargs)
 def render_next_step(self, form, **kwargs):
     """
     When using the NamedUrlWizardView, we have to redirect to update the
     browser's URL to match the shown step.
     """
     next_step = self.get_next_step()
     self.storage.current_step = next_step
     return redirect(self.get_step_url(next_step))
 def post(self, *args, **kwargs):
     """
     Do a redirect if user presses the prev. step button. The rest of this
     is super'd from WizardView.
     """
     wizard_goto_step = self.request.POST.get('wizard_goto_step', None)
     if wizard_goto_step and wizard_goto_step in self.get_form_list():
         self.storage.current_step = wizard_goto_step
         return redirect(self.get_step_url(wizard_goto_step))
     return super(NamedUrlWizardView, self).post(*args, **kwargs)