Continue to attack E302 violations
This commit is contained in:
@@ -14,21 +14,25 @@ from django.contrib.formtools.wizard.views import NamedUrlWizardView
|
||||
temp_storage_location = tempfile.mkdtemp(dir=os.environ.get('DJANGO_TEST_TEMP_DIR'))
|
||||
temp_storage = FileSystemStorage(location=temp_storage_location)
|
||||
|
||||
|
||||
class Page1(forms.Form):
|
||||
name = forms.CharField(max_length=100)
|
||||
user = forms.ModelChoiceField(queryset=User.objects.all())
|
||||
thirsty = forms.NullBooleanField()
|
||||
|
||||
|
||||
class Page2(forms.Form):
|
||||
address1 = forms.CharField(max_length=100)
|
||||
address2 = forms.CharField(max_length=100)
|
||||
file1 = forms.FileField()
|
||||
|
||||
|
||||
class Page3(forms.Form):
|
||||
random_crap = forms.CharField(max_length=100)
|
||||
|
||||
Page4 = formset_factory(Page3, extra=2)
|
||||
|
||||
|
||||
class ContactWizard(NamedUrlWizardView):
|
||||
file_storage = temp_storage
|
||||
|
||||
@@ -44,8 +48,10 @@ class ContactWizard(NamedUrlWizardView):
|
||||
c['this_will_fail'] = self.get_cleaned_data_for_step('this_will_fail')
|
||||
return HttpResponse(Template('').render(c))
|
||||
|
||||
|
||||
class SessionContactWizard(ContactWizard):
|
||||
storage_name = 'django.contrib.formtools.wizard.storage.session.SessionStorage'
|
||||
|
||||
|
||||
class CookieContactWizard(ContactWizard):
|
||||
storage_name = 'django.contrib.formtools.wizard.storage.cookie.CookieStorage'
|
||||
|
||||
@@ -2,6 +2,7 @@ from django.conf.urls import patterns, url
|
||||
from django.contrib.formtools.tests.wizard.namedwizardtests.forms import (
|
||||
SessionContactWizard, CookieContactWizard, Page1, Page2, Page3, Page4)
|
||||
|
||||
|
||||
def get_named_session_wizard():
|
||||
return SessionContactWizard.as_view(
|
||||
[('form1', Page1), ('form2', Page2), ('form3', Page3), ('form4', Page4)],
|
||||
@@ -9,6 +10,7 @@ def get_named_session_wizard():
|
||||
done_step_name='nwiz_session_done'
|
||||
)
|
||||
|
||||
|
||||
def get_named_cookie_wizard():
|
||||
return CookieContactWizard.as_view(
|
||||
[('form1', Page1), ('form2', Page2), ('form3', Page3), ('form4', Page4)],
|
||||
|
||||
@@ -81,12 +81,14 @@ class TestWizard(WizardView):
|
||||
kwargs['test'] = True
|
||||
return kwargs
|
||||
|
||||
|
||||
class TestWizardWithInitAttrs(TestWizard):
|
||||
form_list = [Step1, Step2]
|
||||
condition_dict = {'step2': True}
|
||||
initial_dict = {'start': {'name': 'value1'}}
|
||||
instance_dict = {'start': User()}
|
||||
|
||||
|
||||
class FormTests(TestCase):
|
||||
def test_form_init(self):
|
||||
testform = TestWizard.get_initkwargs([Step1, Step2])
|
||||
|
||||
@@ -15,21 +15,25 @@ from django.contrib.formtools.wizard.views import WizardView
|
||||
temp_storage_location = tempfile.mkdtemp(dir=os.environ.get('DJANGO_TEST_TEMP_DIR'))
|
||||
temp_storage = FileSystemStorage(location=temp_storage_location)
|
||||
|
||||
|
||||
class Page1(forms.Form):
|
||||
name = forms.CharField(max_length=100)
|
||||
user = forms.ModelChoiceField(queryset=User.objects.all())
|
||||
thirsty = forms.NullBooleanField()
|
||||
|
||||
|
||||
class Page2(forms.Form):
|
||||
address1 = forms.CharField(max_length=100)
|
||||
address2 = forms.CharField(max_length=100)
|
||||
file1 = forms.FileField()
|
||||
|
||||
|
||||
class Page3(forms.Form):
|
||||
random_crap = forms.CharField(max_length=100)
|
||||
|
||||
Page4 = formset_factory(Page3, extra=2)
|
||||
|
||||
|
||||
class ContactWizard(WizardView):
|
||||
file_storage = temp_storage
|
||||
|
||||
@@ -51,6 +55,7 @@ class ContactWizard(WizardView):
|
||||
context.update({'another_var': True})
|
||||
return context
|
||||
|
||||
|
||||
class UserForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = User
|
||||
@@ -58,8 +63,10 @@ class UserForm(forms.ModelForm):
|
||||
|
||||
UserFormSet = modelformset_factory(User, form=UserForm)
|
||||
|
||||
|
||||
class SessionContactWizard(ContactWizard):
|
||||
storage_name = 'django.contrib.formtools.wizard.storage.session.SessionStorage'
|
||||
|
||||
|
||||
class CookieContactWizard(ContactWizard):
|
||||
storage_name = 'django.contrib.formtools.wizard.storage.cookie.CookieStorage'
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from django import forms
|
||||
|
||||
|
||||
class ManagementForm(forms.Form):
|
||||
"""
|
||||
``ManagementForm`` is used to keep track of the current wizard step.
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
|
||||
|
||||
class MissingStorage(ImproperlyConfigured):
|
||||
pass
|
||||
|
||||
|
||||
class NoFileStorageConfigured(ImproperlyConfigured):
|
||||
pass
|
||||
|
||||
@@ -28,6 +28,7 @@ def normalize_name(name):
|
||||
new = re.sub('(((?<=[a-z])[A-Z])|([A-Z](?![A-Z]|$)))', '_\\1', name)
|
||||
return new.lower().strip('_')
|
||||
|
||||
|
||||
class StepsHelper(object):
|
||||
|
||||
def __init__(self, wizard):
|
||||
|
||||
Reference in New Issue
Block a user