summaryrefslogtreecommitdiff
path: root/django/forms
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2013-11-02 13:12:09 -0700
committerAlex Gaynor <alex.gaynor@gmail.com>2013-11-02 13:12:09 -0700
commit7548aa8ffd46eb6e0f73730d1b2eb515ba581f95 (patch)
tree963393779f4c8c33351ea605f708f8da7d9f70bf /django/forms
parent65c4ac3b2434d1828cb76c9f4454fe64e81354ee (diff)
More attacking E302 violators
Diffstat (limited to 'django/forms')
-rw-r--r--django/forms/forms.py1
-rw-r--r--django/forms/formsets.py4
-rw-r--r--django/forms/utils.py5
-rw-r--r--django/forms/widgets.py2
4 files changed, 12 insertions, 0 deletions
diff --git a/django/forms/forms.py b/django/forms/forms.py
index ddd51ffaae..51a3b928ae 100644
--- a/django/forms/forms.py
+++ b/django/forms/forms.py
@@ -23,6 +23,7 @@ __all__ = ('BaseForm', 'Form')
NON_FIELD_ERRORS = '__all__'
+
def pretty_name(name):
"""Converts 'first_name' to 'First name'"""
if not name:
diff --git a/django/forms/formsets.py b/django/forms/formsets.py
index 5b2efee82e..9c8b790d59 100644
--- a/django/forms/formsets.py
+++ b/django/forms/formsets.py
@@ -29,6 +29,7 @@ DEFAULT_MIN_NUM = 0
# default maximum number of forms in a formset, to prevent memory exhaustion
DEFAULT_MAX_NUM = 1000
+
class ManagementForm(Form):
"""
``ManagementForm`` is used to keep track of how many form instances
@@ -45,6 +46,7 @@ class ManagementForm(Form):
self.base_fields[MAX_NUM_FORM_COUNT] = IntegerField(required=False, widget=HiddenInput)
super(ManagementForm, self).__init__(*args, **kwargs)
+
@python_2_unicode_compatible
class BaseFormSet(object):
"""
@@ -407,6 +409,7 @@ class BaseFormSet(object):
forms = ' '.join(form.as_ul() for form in self)
return mark_safe('\n'.join([six.text_type(self.management_form), forms]))
+
def formset_factory(form, formset=BaseFormSet, extra=1, can_order=False,
can_delete=False, max_num=None, validate_max=False,
min_num=None, validate_min=False):
@@ -427,6 +430,7 @@ def formset_factory(form, formset=BaseFormSet, extra=1, can_order=False,
'validate_max': validate_max}
return type(form.__name__ + str('FormSet'), (formset,), attrs)
+
def all_valid(formsets):
"""Returns true if every formset in formsets is valid."""
valid = True
diff --git a/django/forms/utils.py b/django/forms/utils.py
index 106074be5c..85297b1a1e 100644
--- a/django/forms/utils.py
+++ b/django/forms/utils.py
@@ -14,6 +14,7 @@ import sys
# module to maintain backwards compatibility.
from django.core.exceptions import ValidationError
+
def flatatt(attrs):
"""
Convert a dictionary of attributes to a single string.
@@ -37,6 +38,7 @@ def flatatt(attrs):
)
return format_html_join('', ' {0}="{1}"', sorted(attrs.items()))
+
@python_2_unicode_compatible
class ErrorDict(dict):
"""
@@ -59,6 +61,7 @@ class ErrorDict(dict):
def as_text(self):
return '\n'.join('* %s\n%s' % (k, '\n'.join(' * %s' % force_text(i) for i in v)) for k, v in self.items())
+
@python_2_unicode_compatible
class ErrorList(list):
"""
@@ -84,6 +87,7 @@ class ErrorList(list):
def __repr__(self):
return repr([force_text(e) for e in self])
+
# Utilities for time zone support in DateTimeField et al.
def from_current_timezone(value):
@@ -109,6 +113,7 @@ def from_current_timezone(value):
), sys.exc_info()[2])
return value
+
def to_current_timezone(value):
"""
When time zone support is enabled, convert aware datetimes
diff --git a/django/forms/widgets.py b/django/forms/widgets.py
index 55ccada4a1..88dc28d664 100644
--- a/django/forms/widgets.py
+++ b/django/forms/widgets.py
@@ -30,6 +30,7 @@ __all__ = (
MEDIA_TYPES = ('css', 'js')
+
@python_2_unicode_compatible
class Media(object):
def __init__(self, media=None, **kwargs):
@@ -143,6 +144,7 @@ class MediaDefiningClass(type):
return new_class
+
@python_2_unicode_compatible
class SubWidget(object):
"""