mirror of
https://github.com/django/django.git
synced 2025-07-05 18:29:11 +00:00
new-admin: Negligible formatting changes to django/core/meta/fields.py
git-svn-id: http://code.djangoproject.com/svn/django/branches/new-admin@1414 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
88fb208912
commit
5c60773256
@ -59,7 +59,6 @@ def manipulator_validator_unique(f, opts, self, field_data, all_data):
|
|||||||
return
|
return
|
||||||
raise validators.ValidationError, _("%(optname)s with this %(fieldname)s already exists.") % {'optname': capfirst(opts.verbose_name), 'fieldname': f.verbose_name}
|
raise validators.ValidationError, _("%(optname)s with this %(fieldname)s already exists.") % {'optname': capfirst(opts.verbose_name), 'fieldname': f.verbose_name}
|
||||||
|
|
||||||
|
|
||||||
class BoundField(object):
|
class BoundField(object):
|
||||||
def __init__(self, field, field_mapping, original):
|
def __init__(self, field, field_mapping, original):
|
||||||
self.field = field
|
self.field = field
|
||||||
@ -79,7 +78,6 @@ class BoundField(object):
|
|||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "BoundField:(%s, %s)" % (self.field.name, self.form_fields)
|
return "BoundField:(%s, %s)" % (self.field.name, self.form_fields)
|
||||||
|
|
||||||
|
|
||||||
# A guide to Field parameters:
|
# A guide to Field parameters:
|
||||||
#
|
#
|
||||||
# * name: The name of the field specifed in the model.
|
# * name: The name of the field specifed in the model.
|
||||||
@ -310,7 +308,6 @@ class Field(object):
|
|||||||
|
|
||||||
def get_choices(self, include_blank=True, blank_choice=BLANK_CHOICE_DASH):
|
def get_choices(self, include_blank=True, blank_choice=BLANK_CHOICE_DASH):
|
||||||
"Returns a list of tuples used as SelectField choices for this field."
|
"Returns a list of tuples used as SelectField choices for this field."
|
||||||
|
|
||||||
first_choice = include_blank and blank_choice or []
|
first_choice = include_blank and blank_choice or []
|
||||||
if self.choices:
|
if self.choices:
|
||||||
return first_choice + list(self.choices)
|
return first_choice + list(self.choices)
|
||||||
@ -333,8 +330,8 @@ class Field(object):
|
|||||||
def flatten_data(self, follow, obj = None):
|
def flatten_data(self, follow, obj = None):
|
||||||
"""
|
"""
|
||||||
Returns a dictionary mapping the field's manipulator field names to its
|
Returns a dictionary mapping the field's manipulator field names to its
|
||||||
"flattened" string values for the admin view. Obj is the instance to extract the
|
"flattened" string values for the admin view. obj is the instance to
|
||||||
values from.
|
extract the values from.
|
||||||
"""
|
"""
|
||||||
return {self.attname: self._get_val_from_obj(obj)}
|
return {self.attname: self._get_val_from_obj(obj)}
|
||||||
|
|
||||||
@ -869,14 +866,12 @@ class OneToOne(ManyToOne):
|
|||||||
|
|
||||||
class BoundFieldLine(object):
|
class BoundFieldLine(object):
|
||||||
def __init__(self, field_line, field_mapping, original, bound_field_class=BoundField):
|
def __init__(self, field_line, field_mapping, original, bound_field_class=BoundField):
|
||||||
self.bound_fields = [field.bind(field_mapping, original, bound_field_class)
|
self.bound_fields = [field.bind(field_mapping, original, bound_field_class) for field in field_line]
|
||||||
for field in field_line]
|
|
||||||
|
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
for bound_field in self.bound_fields:
|
for bound_field in self.bound_fields:
|
||||||
yield bound_field
|
yield bound_field
|
||||||
|
|
||||||
|
|
||||||
def __len__(self):
|
def __len__(self):
|
||||||
return len(self.bound_fields)
|
return len(self.bound_fields)
|
||||||
|
|
||||||
@ -901,8 +896,7 @@ class BoundFieldSet(object):
|
|||||||
def __init__(self, field_set, field_mapping, original, bound_field_line_class=BoundFieldLine):
|
def __init__(self, field_set, field_mapping, original, bound_field_line_class=BoundFieldLine):
|
||||||
self.name = field_set.name
|
self.name = field_set.name
|
||||||
self.classes = field_set.classes
|
self.classes = field_set.classes
|
||||||
self.bound_field_lines = [ field_line.bind(field_mapping,original, bound_field_line_class)
|
self.bound_field_lines = [field_line.bind(field_mapping,original, bound_field_line_class) for field_line in field_set]
|
||||||
for field_line in field_set]
|
|
||||||
|
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
for bound_field_line in self.bound_field_lines:
|
for bound_field_line in self.bound_field_lines:
|
||||||
@ -950,7 +944,6 @@ class Admin:
|
|||||||
}),)
|
}),)
|
||||||
else:
|
else:
|
||||||
field_struct = self.fields
|
field_struct = self.fields
|
||||||
|
|
||||||
new_fieldset_list = []
|
new_fieldset_list = []
|
||||||
for fieldset in field_struct:
|
for fieldset in field_struct:
|
||||||
name = fieldset[0]
|
name = fieldset[0]
|
||||||
@ -959,5 +952,3 @@ class Admin:
|
|||||||
line_specs = fs_options['fields']
|
line_specs = fs_options['fields']
|
||||||
new_fieldset_list.append(FieldSet(name, classes, opts.get_field, line_specs))
|
new_fieldset_list.append(FieldSet(name, classes, opts.get_field, line_specs))
|
||||||
return new_fieldset_list
|
return new_fieldset_list
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user