Ticket #17163: 17163.diff
File 17163.diff, 4.0 KB (added by , 13 years ago) |
---|
-
docs/ref/contrib/formtools/form-wizard.txt
559 559 ``ModelFormSet``. Similarly to :attr:`~WizardView.initial_dict`, these 560 560 dictionary key values should be equal to the step number in the form list. 561 561 562 Usage of NamedUrlWizardView563 =========================== 562 Usage of ``NamedUrlWizardView`` 563 =============================== 564 564 565 565 .. class:: NamedUrlWizardView 566 566 … … 597 597 url(r'^contact/(?P<step>.+)/$', contact_wizard, name='contact_step'), 598 598 url(r'^contact/$', contact_wizard, name='contact'), 599 599 ) 600 601 Advanced ``NamedUrlWizardView`` methods 602 ======================================= 603 604 .. method:: NamedUrlWizardView.get_step_url(step) 605 606 This method returns the URL for a specific step. 607 608 Default implementation:: 609 610 def get_step_url(self, step): 611 return reverse(self.url_name, kwargs={'step': step}) -
django/contrib/formtools/wizard/views.py
586 586 'step name "%s" is reserved for "done" view' % initkwargs['done_step_name'] 587 587 return initkwargs 588 588 589 def get_step_url(self, step): 590 return reverse(self.url_name, kwargs={'step': step}) 591 589 592 def get(self, *args, **kwargs): 590 593 """ 591 594 This renders the form or, if needed, does the http redirects. … … 599 602 query_string = "?%s" % self.request.GET.urlencode() 600 603 else: 601 604 query_string = "" 602 next_step_url = reverse(self.url_name, kwargs={ 603 'step': self.steps.current, 604 }) + query_string 605 return redirect(next_step_url) 605 return redirect(self.get_step_url(self.steps.current) 606 + query_string) 606 607 607 608 # is the current step the "done" name/view? 608 609 elif step_url == self.done_step_name: … … 631 632 # invalid step name, reset to first and redirect. 632 633 else: 633 634 self.storage.current_step = self.steps.first 634 return redirect(self. url_name, step=self.steps.first)635 return redirect(self.get_step_url(self.steps.first)) 635 636 636 637 def post(self, *args, **kwargs): 637 638 """ … … 641 642 prev_step = self.request.POST.get('wizard_prev_step', None) 642 643 if prev_step and prev_step in self.get_form_list(): 643 644 self.storage.current_step = prev_step 644 return redirect(self. url_name, step=prev_step)645 return redirect(self.get_step_url(prev_step)) 645 646 return super(NamedUrlWizardView, self).post(*args, **kwargs) 646 647 647 648 def render_next_step(self, form, **kwargs): … … 651 652 """ 652 653 next_step = self.get_next_step() 653 654 self.storage.current_step = next_step 654 return redirect(self. url_name, step=next_step)655 return redirect(self.get_step_url(next_step)) 655 656 656 657 def render_revalidation_failure(self, failed_step, form, **kwargs): 657 658 """ … … 659 660 step. 660 661 """ 661 662 self.storage.current_step = failed_step 662 return redirect(self. url_name, step=failed_step)663 return redirect(self.get_step_url(failed_step)) 663 664 664 665 def render_done(self, form, **kwargs): 665 666 """ … … 667 668 name doesn't fit). 668 669 """ 669 670 if kwargs.get('step', None) != self.done_step_name: 670 return redirect(self. url_name, step=self.done_step_name)671 return redirect(self.get_step_url(self.done_step_name)) 671 672 return super(NamedUrlWizardView, self).render_done(form, **kwargs) 672 673 673 674 … … 683 684 A NamedUrlFormWizard with pre-configured CookieStorageBackend. 684 685 """ 685 686 storage_name = 'django.contrib.formtools.wizard.storage.cookie.CookieStorage' 686