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
@ -57,8 +57,7 @@ def manipulator_validator_unique(f, opts, self, field_data, all_data):
|
||||
return
|
||||
if hasattr(self, 'original_object') and getattr(self.original_object, opts.pk.attname) == getattr(old_obj, opts.pk.attname):
|
||||
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):
|
||||
def __init__(self, field, field_mapping, original):
|
||||
@ -77,8 +76,7 @@ class BoundField(object):
|
||||
return self.original.__dict__[self.field.column]
|
||||
|
||||
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:
|
||||
#
|
||||
@ -310,7 +308,6 @@ class Field(object):
|
||||
|
||||
def get_choices(self, include_blank=True, blank_choice=BLANK_CHOICE_DASH):
|
||||
"Returns a list of tuples used as SelectField choices for this field."
|
||||
|
||||
first_choice = include_blank and blank_choice or []
|
||||
if self.choices:
|
||||
return first_choice + list(self.choices)
|
||||
@ -333,10 +330,10 @@ class Field(object):
|
||||
def flatten_data(self, follow, obj = None):
|
||||
"""
|
||||
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
|
||||
values from.
|
||||
"flattened" string values for the admin view. obj is the instance to
|
||||
extract the values from.
|
||||
"""
|
||||
return { self.attname : self._get_val_from_obj(obj)}
|
||||
return {self.attname: self._get_val_from_obj(obj)}
|
||||
|
||||
def get_follow(self, override=None):
|
||||
if override != None:
|
||||
@ -869,14 +866,12 @@ class OneToOne(ManyToOne):
|
||||
|
||||
class BoundFieldLine(object):
|
||||
def __init__(self, field_line, field_mapping, original, bound_field_class=BoundField):
|
||||
self.bound_fields = [field.bind(field_mapping, original, bound_field_class)
|
||||
for field in field_line]
|
||||
self.bound_fields = [field.bind(field_mapping, original, bound_field_class) for field in field_line]
|
||||
|
||||
def __iter__(self):
|
||||
for bound_field in self.bound_fields:
|
||||
yield bound_field
|
||||
|
||||
|
||||
def __len__(self):
|
||||
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):
|
||||
self.name = field_set.name
|
||||
self.classes = field_set.classes
|
||||
self.bound_field_lines = [ field_line.bind(field_mapping,original, bound_field_line_class)
|
||||
for field_line in field_set]
|
||||
self.bound_field_lines = [field_line.bind(field_mapping,original, bound_field_line_class) for field_line in field_set]
|
||||
|
||||
def __iter__(self):
|
||||
for bound_field_line in self.bound_field_lines:
|
||||
@ -950,14 +944,11 @@ class Admin:
|
||||
}),)
|
||||
else:
|
||||
field_struct = self.fields
|
||||
|
||||
new_fieldset_list = []
|
||||
for fieldset in field_struct:
|
||||
name = fieldset[0]
|
||||
fs_options = fieldset[1]
|
||||
classes = fs_options.get('classes', () )
|
||||
classes = fs_options.get('classes', ())
|
||||
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
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user