Ticket #18000: wizard_save_goto_step.diff
File wizard_save_goto_step.diff, 2.8 KB (added by , 13 years ago) |
---|
-
django/contrib/formtools/wizard/views.py
246 246 247 247 The wizard will render either the current step (if form validation 248 248 wasn't successful), the next step (if the current step was stored 249 successful ) or the done view (if no more steps are available)249 successfully) or the done view (if no more steps are available) 250 250 """ 251 251 # Look for a wizard_goto_step element in the posted data which 252 252 # contains a valid step name. If one was found, render the requested 253 253 # form. (This makes stepping back a lot easier). 254 wizard_goto_step = self.request.POST.get('wizard_goto_step', None) 255 if wizard_goto_step and wizard_goto_step in self.get_form_list(): 256 self.storage.current_step = wizard_goto_step 257 form = self.get_form( 258 data=self.storage.get_step_data(self.steps.current), 259 files=self.storage.get_step_files(self.steps.current)) 260 return self.render(form) 254 wizard_cancel_step_goto = self.request.POST.get( 255 'wizard_cancel_step_goto', None) 256 if wizard_cancel_step_goto and wizard_cancel_step_goto in \ 257 self.get_form_list(): 258 return self.render_step(wizard_cancel_step_goto) 261 259 262 260 # Check if form was refreshed 263 261 management_form = ManagementForm(self.request.POST, prefix=self.prefix) … … 280 278 self.storage.set_step_data(self.steps.current, self.process_step(form)) 281 279 self.storage.set_step_files(self.steps.current, self.process_step_files(form)) 282 280 281 # check if this is a goto step 282 wizard_goto_step = self.request.POST.get('wizard_goto_step', None) 283 if wizard_goto_step and wizard_goto_step in self.get_form_list(): 284 return self.render_step(wizard_goto_step) 285 283 286 # check if the current step is the last step 284 287 if self.steps.current == self.steps.last: 285 288 # no more steps, render done view … … 553 556 raise NotImplementedError("Your %s class has not defined a done() " 554 557 "method, which is required." % self.__class__.__name__) 555 558 559 def render_step ( self, step ): 560 """ 561 This method is used to render a given step. `step` contains the step-name. 562 """ 563 self.storage.current_step = step 564 form = self.get_form( 565 data=self.storage.get_step_data(self.steps.current), 566 files=self.storage.get_step_files(self.steps.current)) 567 return self.render(form) 556 568 569 557 570 class SessionWizardView(WizardView): 558 571 """ 559 572 A WizardView with pre-configured SessionStorage backend.