magic-removal: Small manipulator simplification. Deletion fix for edit inline.
git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@1752 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
3ee086f80d
commit
d316f6a8cd
|
@ -220,7 +220,7 @@ class Model(object):
|
|||
|
||||
def delete(self, ignore_objects=None):
|
||||
assert getattr(self, self._meta.pk.attname) is not None, "%r can't be deleted because it doesn't have an ID."
|
||||
ignore_objects = ignore_objects and dict([(o.__class,o.__get_pk_val) for o in ignore_objects]) or {}
|
||||
ignore_objects = ignore_objects and dict([(o.__class__,o.__get_pk_val()) for o in ignore_objects]) or {}
|
||||
|
||||
seen_objs = {}
|
||||
self.__collect_sub_objects(seen_objs, ignore_objects)
|
||||
|
|
|
@ -213,7 +213,7 @@ class Field(object):
|
|||
field_objs = self.get_manipulator_field_objs()
|
||||
return (field_objs,params)
|
||||
|
||||
def get_manipulator_fields(self, opts, manipulator, change, name_prefix='', rel=False):
|
||||
def get_manipulator_fields(self, opts, manipulator, change, name_prefix='', rel=False, follow=True):
|
||||
"""
|
||||
Returns a list of formfields.FormField instances for this field. It
|
||||
calculates the choices at runtime, not at compile time.
|
||||
|
@ -326,10 +326,10 @@ class AutoField(Field):
|
|||
assert kwargs.get('primary_key', False) is True, "%ss must have primary_key=True." % self.__class__.__name__
|
||||
Field.__init__(self, *args, **kwargs)
|
||||
|
||||
def get_manipulator_fields(self, opts, manipulator, change, name_prefix='', rel=False):
|
||||
def get_manipulator_fields(self, opts, manipulator, change, name_prefix='', rel=False, follow=True):
|
||||
if not rel:
|
||||
return [] # Don't add a FormField unless it's in a related context.
|
||||
return Field.get_manipulator_fields(self, opts, manipulator, change, name_prefix, rel)
|
||||
return Field.get_manipulator_fields(self, opts, manipulator, change, name_prefix, rel, follow)
|
||||
|
||||
def get_manipulator_field_objs(self):
|
||||
return [formfields.HiddenField]
|
||||
|
@ -462,8 +462,8 @@ class FileField(Field):
|
|||
self.upload_to = upload_to
|
||||
Field.__init__(self, verbose_name, name, **kwargs)
|
||||
|
||||
def get_manipulator_fields(self, opts, manipulator, change, name_prefix='', rel=False):
|
||||
field_list = Field.get_manipulator_fields(self, opts, manipulator, change, name_prefix, rel)
|
||||
def get_manipulator_fields(self, opts, manipulator, change, name_prefix='', rel=False, follow=True):
|
||||
field_list = Field.get_manipulator_fields(self, opts, manipulator, change, name_prefix, rel, follow)
|
||||
|
||||
if not self.blank:
|
||||
if rel:
|
||||
|
|
|
@ -19,7 +19,6 @@ def add_lookup(rel_cls, field):
|
|||
key = (module, name)
|
||||
pending_lookups.setdefault(key, []).append((rel_cls, field))
|
||||
|
||||
|
||||
def do_pending_lookups(sender):
|
||||
other_cls = sender
|
||||
key = (other_cls.__module__, other_cls.__name__)
|
||||
|
|
|
@ -72,15 +72,9 @@ class AutomaticManipulator(Manipulator):
|
|||
self.follow = self.model._meta.get_follow(follow)
|
||||
self.fields = []
|
||||
self.original_object = original_object
|
||||
for f in self.opts.fields + self.opts.many_to_many:
|
||||
if self.follow.get(f.name, False):
|
||||
self.fields.extend(f.get_manipulator_fields(self.opts, self, self.change))
|
||||
|
||||
# Add fields for related objects.
|
||||
for f in self.opts.get_all_related_objects():
|
||||
if self.follow.get(f.name, False):
|
||||
for f in self.opts.get_data_holders(self.follow):
|
||||
fol = self.follow[f.name]
|
||||
fields = f.get_manipulator_fields(self.opts, self, self.change, fol)
|
||||
fields = f.get_manipulator_fields(self.opts, self, self.change, follow=fol)
|
||||
self.fields.extend(fields)
|
||||
|
||||
def save(self, new_data):
|
||||
|
|
Loading…
Reference in New Issue