Skip to content

Commit

Permalink
Continue to attack E302 violations
Browse files Browse the repository at this point in the history
  • Loading branch information
alex committed Nov 2, 2013
1 parent 8b3d9d9 commit 19256f3
Show file tree
Hide file tree
Showing 67 changed files with 171 additions and 2 deletions.
Expand Up @@ -14,21 +14,25 @@
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

Expand All @@ -44,8 +48,10 @@ def done(self, form_list, **kwargs):
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'
Expand Up @@ -2,13 +2,15 @@
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)],
url_name='nwiz_session',
done_step_name='nwiz_session_done'
)


def get_named_cookie_wizard():
return CookieContactWizard.as_view(
[('form1', Page1), ('form2', Page2), ('form3', Page3), ('form4', Page4)],
Expand Down
2 changes: 2 additions & 0 deletions django/contrib/formtools/tests/wizard/test_forms.py
Expand Up @@ -81,12 +81,14 @@ def get_form_kwargs(self, step, *args, **kwargs):
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])
Expand Down
7 changes: 7 additions & 0 deletions django/contrib/formtools/tests/wizard/wizardtests/forms.py
Expand Up @@ -15,21 +15,25 @@
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

Expand All @@ -51,15 +55,18 @@ def get_context_data(self, form, **kwargs):
context.update({'another_var': True})
return context


class UserForm(forms.ModelForm):
class Meta:
model = User
fields = ('username', 'email')

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 change: 1 addition & 0 deletions django/contrib/formtools/wizard/forms.py
@@ -1,5 +1,6 @@
from django import forms


class ManagementForm(forms.Form):
"""
``ManagementForm`` is used to keep track of the current wizard step.
Expand Down
2 changes: 2 additions & 0 deletions django/contrib/formtools/wizard/storage/exceptions.py
@@ -1,7 +1,9 @@
from django.core.exceptions import ImproperlyConfigured


class MissingStorage(ImproperlyConfigured):
pass


class NoFileStorageConfigured(ImproperlyConfigured):
pass
1 change: 1 addition & 0 deletions django/contrib/formtools/wizard/views.py
Expand Up @@ -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):
Expand Down
1 change: 1 addition & 0 deletions django/contrib/gis/admin/options.py
Expand Up @@ -3,6 +3,7 @@
from django.contrib.gis.gdal import OGRGeomType
from django.contrib.gis.db import models


class GeoModelAdmin(ModelAdmin):
"""
The administration options class for Geographic models. Map settings
Expand Down
1 change: 1 addition & 0 deletions django/contrib/gis/db/backends/base.py
Expand Up @@ -143,6 +143,7 @@ def geometry_columns(self):
def spatial_ref_sys(self):
raise NotImplementedError('subclasses of BaseSpatialOperations must a provide spatial_ref_sys() method')


@python_2_unicode_compatible
class SpatialRefSysMixin(object):
"""
Expand Down
6 changes: 6 additions & 0 deletions django/contrib/gis/db/backends/mysql/compiler.py
Expand Up @@ -3,6 +3,7 @@

SQLCompiler = compiler.SQLCompiler


class GeoSQLCompiler(BaseGeoSQLCompiler, SQLCompiler):
def resolve_columns(self, row, fields=()):
"""
Expand All @@ -19,17 +20,22 @@ def resolve_columns(self, row, fields=()):
class SQLInsertCompiler(compiler.SQLInsertCompiler, GeoSQLCompiler):
pass


class SQLDeleteCompiler(compiler.SQLDeleteCompiler, GeoSQLCompiler):
pass


class SQLUpdateCompiler(compiler.SQLUpdateCompiler, GeoSQLCompiler):
pass


class SQLAggregateCompiler(compiler.SQLAggregateCompiler, GeoSQLCompiler):
pass


class SQLDateCompiler(compiler.SQLDateCompiler, GeoSQLCompiler):
pass


class SQLDateTimeCompiler(compiler.SQLDateTimeCompiler, GeoSQLCompiler):
pass
2 changes: 1 addition & 1 deletion django/contrib/gis/db/backends/mysql/creation.py
@@ -1,7 +1,7 @@
from django.db.backends.mysql.creation import DatabaseCreation

class MySQLCreation(DatabaseCreation):

class MySQLCreation(DatabaseCreation):
def sql_indexes_for_field(self, model, f, style):
from django.contrib.gis.db.models.fields import GeometryField
output = super(MySQLCreation, self).sql_indexes_for_field(model, f, style)
Expand Down
1 change: 1 addition & 0 deletions django/contrib/gis/db/backends/mysql/introspection.py
Expand Up @@ -3,6 +3,7 @@
from django.contrib.gis.gdal import OGRGeomType
from django.db.backends.mysql.introspection import DatabaseIntrospection


class MySQLIntrospection(DatabaseIntrospection):
# Updating the data_types_reverse dictionary with the appropriate
# type for Geometry fields.
Expand Down
1 change: 1 addition & 0 deletions django/contrib/gis/db/backends/oracle/adapter.py
@@ -1,5 +1,6 @@
from cx_Oracle import CLOB
from django.contrib.gis.db.backends.adapter import WKTAdapter


class OracleSpatialAdapter(WKTAdapter):
input_size = CLOB
7 changes: 7 additions & 0 deletions django/contrib/gis/db/backends/oracle/compiler.py
Expand Up @@ -3,23 +3,30 @@

SQLCompiler = compiler.SQLCompiler


class GeoSQLCompiler(BaseGeoSQLCompiler, SQLCompiler):
pass


class SQLInsertCompiler(compiler.SQLInsertCompiler, GeoSQLCompiler):
pass


class SQLDeleteCompiler(compiler.SQLDeleteCompiler, GeoSQLCompiler):
pass


class SQLUpdateCompiler(compiler.SQLUpdateCompiler, GeoSQLCompiler):
pass


class SQLAggregateCompiler(compiler.SQLAggregateCompiler, GeoSQLCompiler):
pass


class SQLDateCompiler(compiler.SQLDateCompiler, GeoSQLCompiler):
pass


class SQLDateTimeCompiler(compiler.SQLDateTimeCompiler, GeoSQLCompiler):
pass
1 change: 1 addition & 0 deletions django/contrib/gis/db/backends/oracle/creation.py
@@ -1,6 +1,7 @@
from django.db.backends.oracle.creation import DatabaseCreation
from django.db.backends.utils import truncate_name


class OracleCreation(DatabaseCreation):

def sql_indexes_for_field(self, model, f, style):
Expand Down
1 change: 1 addition & 0 deletions django/contrib/gis/db/backends/oracle/introspection.py
Expand Up @@ -3,6 +3,7 @@
from django.db.backends.oracle.introspection import DatabaseIntrospection
from django.utils import six


class OracleIntrospection(DatabaseIntrospection):
# Associating any OBJECTVAR instances with GeometryField. Of course,
# this won't work right on Oracle objects that aren't MDSYS.SDO_GEOMETRY,
Expand Down
2 changes: 2 additions & 0 deletions django/contrib/gis/db/backends/oracle/models.py
Expand Up @@ -11,6 +11,7 @@
from django.contrib.gis.db.backends.base import SpatialRefSysMixin
from django.utils.encoding import python_2_unicode_compatible


@python_2_unicode_compatible
class GeometryColumns(models.Model):
"Maps to the Oracle USER_SDO_GEOM_METADATA table."
Expand Down Expand Up @@ -42,6 +43,7 @@ def geom_col_name(cls):
def __str__(self):
return '%s - %s (SRID: %s)' % (self.table_name, self.column_name, self.srid)


class SpatialRefSys(models.Model, SpatialRefSysMixin):
"Maps to the Oracle MDSYS.CS_SRS table."
cs_name = models.CharField(max_length=68)
Expand Down
5 changes: 5 additions & 0 deletions django/contrib/gis/db/backends/oracle/operations.py
Expand Up @@ -28,6 +28,7 @@ def __init__(self, func, **kwargs):
kwargs.setdefault('result', 'TRUE')
super(SDOOperation, self).__init__(func, **kwargs)


class SDODistance(SpatialFunction):
"Class for Distance queries."
sql_template = ('%(function)s(%(geo_col)s, %(geometry)s, %(tolerance)s) '
Expand All @@ -39,13 +40,15 @@ def __init__(self, op, tolerance=0.05):
tolerance=tolerance,
operator=op, result='%s')


class SDODWithin(SpatialFunction):
dwithin_func = 'SDO_WITHIN_DISTANCE'
sql_template = "%(function)s(%(geo_col)s, %(geometry)s, %%s) = 'TRUE'"

def __init__(self):
super(SDODWithin, self).__init__(self.dwithin_func)


class SDOGeomRelate(SpatialFunction):
"Class for using SDO_GEOM.RELATE."
relate_func = 'SDO_GEOM.RELATE'
Expand All @@ -58,6 +61,7 @@ def __init__(self, mask, tolerance=0.05):
super(SDOGeomRelate, self).__init__(self.relate_func, operator='=',
mask=mask, tolerance=tolerance)


class SDORelate(SpatialFunction):
"Class for using SDO_RELATE."
masks = 'TOUCH|OVERLAPBDYDISJOINT|OVERLAPBDYINTERSECT|EQUAL|INSIDE|COVEREDBY|CONTAINS|COVERS|ANYINTERACT|ON'
Expand All @@ -73,6 +77,7 @@ def __init__(self, mask):
# Valid distance types and substitutions
dtypes = (Decimal, Distance, float) + six.integer_types


class OracleOperations(DatabaseOperations, BaseSpatialOperations):
compiler_module = "django.contrib.gis.db.backends.oracle.compiler"

Expand Down
1 change: 1 addition & 0 deletions django/contrib/gis/db/backends/postgis/adapter.py
Expand Up @@ -6,6 +6,7 @@
from psycopg2 import Binary
from psycopg2.extensions import ISQLQuote


class PostGISAdapter(object):
def __init__(self, geom):
"Initializes on the geometry."
Expand Down
2 changes: 2 additions & 0 deletions django/contrib/gis/db/backends/postgis/introspection.py
@@ -1,9 +1,11 @@
from django.db.backends.postgresql_psycopg2.introspection import DatabaseIntrospection
from django.contrib.gis.gdal import OGRGeomType


class GeoIntrospectionError(Exception):
pass


class PostGISIntrospection(DatabaseIntrospection):
# Reverse dictionary for PostGIS geometry types not populated until
# introspection is actually performed.
Expand Down
2 changes: 2 additions & 0 deletions django/contrib/gis/db/backends/postgis/models.py
Expand Up @@ -5,6 +5,7 @@
from django.contrib.gis.db.backends.base import SpatialRefSysMixin
from django.utils.encoding import python_2_unicode_compatible


@python_2_unicode_compatible
class GeometryColumns(models.Model):
"""
Expand Down Expand Up @@ -44,6 +45,7 @@ def __str__(self):
(self.f_table_name, self.f_geometry_column,
self.coord_dimension, self.type, self.srid)


class SpatialRefSys(models.Model, SpatialRefSysMixin):
"""
The 'spatial_ref_sys' table from PostGIS. See the PostGIS
Expand Down
6 changes: 6 additions & 0 deletions django/contrib/gis/db/backends/postgis/operations.py
Expand Up @@ -22,15 +22,18 @@ class PostGISOperator(SpatialOperation):
def __init__(self, operator):
super(PostGISOperator, self).__init__(operator=operator)


class PostGISFunction(SpatialFunction):
"For PostGIS function calls (e.g., `ST_Contains(table, geom)`)."
def __init__(self, prefix, function, **kwargs):
super(PostGISFunction, self).__init__(prefix + function, **kwargs)


class PostGISFunctionParam(PostGISFunction):
"For PostGIS functions that take another parameter (e.g. DWithin, Relate)."
sql_template = '%(function)s(%(geo_col)s, %(geometry)s, %%s)'


class PostGISDistance(PostGISFunction):
"For PostGIS distance operations."
dist_func = 'Distance'
Expand All @@ -40,6 +43,7 @@ def __init__(self, prefix, operator):
super(PostGISDistance, self).__init__(prefix, self.dist_func,
operator=operator)


class PostGISSpheroidDistance(PostGISFunction):
"For PostGIS spherical distance operations (using the spheroid)."
dist_func = 'distance_spheroid'
Expand All @@ -50,10 +54,12 @@ def __init__(self, prefix, operator):
super(PostGISSpheroidDistance, self).__init__(prefix, self.dist_func,
operator=operator)


class PostGISSphereDistance(PostGISDistance):
"For PostGIS spherical distance operations."
dist_func = 'distance_sphere'


class PostGISRelate(PostGISFunctionParam):
"For PostGIS Relate(<geom>, <pattern>) calls."
pattern_regex = re.compile(r'^[012TF\*]{9}$')
Expand Down
1 change: 1 addition & 0 deletions django/contrib/gis/db/backends/spatialite/adapter.py
@@ -1,6 +1,7 @@
from django.db.backends.sqlite3.base import Database
from django.contrib.gis.db.backends.adapter import WKTAdapter


class SpatiaLiteAdapter(WKTAdapter):
"SQLite adaptor for geometry objects."
def __conform__(self, protocol):
Expand Down

0 comments on commit 19256f3

Please sign in to comment.