1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

More attacking E302 violators

This commit is contained in:
Alex Gaynor
2013-11-02 13:12:09 -07:00
parent 65c4ac3b24
commit 7548aa8ffd
150 changed files with 433 additions and 1 deletions

View File

@@ -23,6 +23,7 @@ __all__ = ('BaseForm', 'Form')
NON_FIELD_ERRORS = '__all__'
def pretty_name(name):
"""Converts 'first_name' to 'First name'"""
if not name:

View File

@@ -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

View File

@@ -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

View File

@@ -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):
"""