Fixed #17408 -- Cleaned up some namings in `contrib.formtools`. Thanks, Stephan Jaekel.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@17236 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Julien Phalip 2011-12-19 13:52:40 +00:00
parent 355f7fc564
commit 259ebcdeea
4 changed files with 19 additions and 19 deletions

View File

@ -4,8 +4,8 @@ from django.contrib.formtools.tests.wizard.loadstorage import TestLoadStorage
from django.contrib.formtools.tests.wizard.namedwizardtests.tests import ( from django.contrib.formtools.tests.wizard.namedwizardtests.tests import (
NamedSessionWizardTests, NamedSessionWizardTests,
NamedCookieWizardTests, NamedCookieWizardTests,
TestNamedUrlSessionFormWizard, TestNamedUrlSessionWizardView,
TestNamedUrlCookieFormWizard, TestNamedUrlCookieWizardView,
NamedSessionFormTests, NamedSessionFormTests,
NamedCookieFormTests, NamedCookieFormTests,
) )

View File

@ -321,24 +321,24 @@ class NamedFormTests(object):
instance.render_done(None) instance.render_done(None)
self.assertEqual(instance.storage.current_step, 'start') self.assertEqual(instance.storage.current_step, 'start')
class TestNamedUrlSessionFormWizard(NamedUrlSessionWizardView): class TestNamedUrlSessionWizardView(NamedUrlSessionWizardView):
def dispatch(self, request, *args, **kwargs): def dispatch(self, request, *args, **kwargs):
response = super(TestNamedUrlSessionFormWizard, self).dispatch(request, *args, **kwargs) response = super(TestNamedUrlSessionWizardView, self).dispatch(request, *args, **kwargs)
return response, self return response, self
class TestNamedUrlCookieFormWizard(NamedUrlCookieWizardView): class TestNamedUrlCookieWizardView(NamedUrlCookieWizardView):
def dispatch(self, request, *args, **kwargs): def dispatch(self, request, *args, **kwargs):
response = super(TestNamedUrlCookieFormWizard, self).dispatch(request, *args, **kwargs) response = super(TestNamedUrlCookieWizardView, self).dispatch(request, *args, **kwargs)
return response, self return response, self
class NamedSessionFormTests(NamedFormTests, TestCase): class NamedSessionFormTests(NamedFormTests, TestCase):
formwizard_class = TestNamedUrlSessionFormWizard formwizard_class = TestNamedUrlSessionWizardView
wizard_urlname = 'nwiz_session' wizard_urlname = 'nwiz_session'
class NamedCookieFormTests(NamedFormTests, TestCase): class NamedCookieFormTests(NamedFormTests, TestCase):
formwizard_class = TestNamedUrlCookieFormWizard formwizard_class = TestNamedUrlCookieWizardView
wizard_urlname = 'nwiz_cookie' wizard_urlname = 'nwiz_cookie'

View File

@ -20,7 +20,7 @@ class CookieStorage(storage.BaseStorage):
except KeyError: except KeyError:
data = None data = None
except BadSignature: except BadSignature:
raise SuspiciousOperation('FormWizard cookie manipulated') raise SuspiciousOperation('WizardView cookie manipulated')
if data is None: if data is None:
return None return None
return json.loads(data, cls=json.JSONDecoder) return json.loads(data, cls=json.JSONDecoder)

View File

@ -111,9 +111,9 @@ class WizardView(TemplateView):
@classonlymethod @classonlymethod
def as_view(cls, *args, **kwargs): def as_view(cls, *args, **kwargs):
""" """
This method is used within urls.py to create unique formwizard This method is used within urls.py to create unique wizardview
instances for every request. We need to override this method because instances for every request. We need to override this method because
we add some kwargs which are needed to make the formwizard usable. we add some kwargs which are needed to make the wizardview usable.
""" """
initkwargs = cls.get_initkwargs(*args, **kwargs) initkwargs = cls.get_initkwargs(*args, **kwargs)
return super(WizardView, cls).as_view(**initkwargs) return super(WizardView, cls).as_view(**initkwargs)
@ -126,7 +126,7 @@ class WizardView(TemplateView):
* `form_list` - is a list of forms. The list entries can be single form * `form_list` - is a list of forms. The list entries can be single form
classes or tuples of (`step_name`, `form_class`). If you pass a list classes or tuples of (`step_name`, `form_class`). If you pass a list
of forms, the formwizard will convert the class list to of forms, the wizardview will convert the class list to
(`zero_based_counter`, `form_class`). This is needed to access the (`zero_based_counter`, `form_class`). This is needed to access the
form for a specific step. form for a specific step.
* `initial_dict` - contains a dictionary of initial data dictionaries. * `initial_dict` - contains a dictionary of initial data dictionaries.
@ -139,7 +139,7 @@ class WizardView(TemplateView):
apply. apply.
* `condition_dict` - contains a dictionary of boolean values or * `condition_dict` - contains a dictionary of boolean values or
callables. If the value of for a specific `step_name` is callable it callables. If the value of for a specific `step_name` is callable it
will be called with the formwizard instance as the only argument. will be called with the wizardview instance as the only argument.
If the return value is true, the step's form will be used. If the return value is true, the step's form will be used.
""" """
kwargs.update({ kwargs.update({
@ -168,13 +168,13 @@ class WizardView(TemplateView):
# we need to override the form variable. # we need to override the form variable.
form = form.form form = form.form
# check if any form contains a FileField, if yes, we need a # check if any form contains a FileField, if yes, we need a
# file_storage added to the formwizard (by subclassing). # file_storage added to the wizardview (by subclassing).
for field in form.base_fields.itervalues(): for field in form.base_fields.itervalues():
if (isinstance(field, forms.FileField) and if (isinstance(field, forms.FileField) and
not hasattr(cls, 'file_storage')): not hasattr(cls, 'file_storage')):
raise NoFileStorageConfigured raise NoFileStorageConfigured
# build the kwargs for the formwizard instances # build the kwargs for the wizardview instances
kwargs['form_list'] = init_form_list kwargs['form_list'] = init_form_list
return kwargs return kwargs
@ -215,7 +215,7 @@ class WizardView(TemplateView):
After processing the request using the `dispatch` method, the After processing the request using the `dispatch` method, the
response gets updated by the storage engine (for example add cookies). response gets updated by the storage engine (for example add cookies).
""" """
# add the storage engine to the current formwizard instance # add the storage engine to the current wizardview instance
self.prefix = self.get_prefix(*args, **kwargs) self.prefix = self.get_prefix(*args, **kwargs)
self.storage = get_storage(self.storage_name, self.prefix, request, self.storage = get_storage(self.storage_name, self.prefix, request,
getattr(self, 'file_storage', None)) getattr(self, 'file_storage', None))
@ -517,7 +517,7 @@ class WizardView(TemplateView):
.. code-block:: python .. code-block:: python
class MyWizard(FormWizard): class MyWizard(WizardView):
def get_context_data(self, form, **kwargs): def get_context_data(self, form, **kwargs):
context = super(MyWizard, self).get_context_data(form=form, **kwargs) context = super(MyWizard, self).get_context_data(form=form, **kwargs)
if self.steps.current == 'my_step_name': if self.steps.current == 'my_step_name':
@ -642,7 +642,7 @@ class NamedUrlWizardView(WizardView):
def post(self, *args, **kwargs): def post(self, *args, **kwargs):
""" """
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 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():
@ -661,7 +661,7 @@ class NamedUrlWizardView(WizardView):
def render_next_step(self, form, **kwargs): def render_next_step(self, form, **kwargs):
""" """
When using the NamedUrlFormWizard, we have to redirect to update the When using the NamedUrlWizardView, we have to redirect to update the
browser's URL to match the shown step. browser's URL to match the shown step.
""" """
next_step = self.get_next_step() next_step = self.get_next_step()