mirror of
https://github.com/django/django.git
synced 2025-07-04 01:39:20 +00:00
new-admin: Negligible formatting changes to django/core/meta/__init__.py
git-svn-id: http://code.djangoproject.com/svn/django/branches/new-admin@1413 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
32ca04e59e
commit
88fb208912
@ -154,7 +154,7 @@ class BoundRelatedObject(object):
|
||||
self.field_mappings = field_mapping[related_object.opts.module_name]
|
||||
|
||||
def template_name(self):
|
||||
raise NotImplementedException
|
||||
raise NotImplementedError
|
||||
|
||||
def __repr__(self):
|
||||
return repr(self.__dict__)
|
||||
@ -173,24 +173,25 @@ class RelatedObject(object):
|
||||
rel_instances = self.get_list(obj)
|
||||
for i, rel_instance in enumerate(rel_instances):
|
||||
instance_data = {}
|
||||
|
||||
for f in self.opts.fields + self.opts.many_to_many:
|
||||
#TODO fix for recursive manipulators.
|
||||
# TODO: Fix for recursive manipulators.
|
||||
fol = follow.get(f.name, None)
|
||||
if fol:
|
||||
field_data = f.flatten_data(fol, rel_instance)
|
||||
for name, value in field_data.items():
|
||||
instance_data['%s.%d.%s' % (self.var_name, i, name)] = value
|
||||
new_data.update(instance_data)
|
||||
|
||||
return new_data
|
||||
|
||||
def extract_data(self, data):
|
||||
"Pull out the data meant for inline objects of this class, ie anything starting with our module name"
|
||||
"""
|
||||
Pull out the data meant for inline objects of this class,
|
||||
i.e. anything starting with our module name.
|
||||
"""
|
||||
return data # TODO
|
||||
|
||||
def get_list(self, parent_instance=None):
|
||||
"Get the list of this type of object from an instance of the parent class"
|
||||
"Get the list of this type of object from an instance of the parent class."
|
||||
if parent_instance != None:
|
||||
func_name = 'get_%s_list' % self.get_method_name_part()
|
||||
func = getattr(parent_instance, func_name)
|
||||
@ -214,8 +215,7 @@ class RelatedObject(object):
|
||||
|
||||
|
||||
def editable_fields(self):
|
||||
"""Get the fields in this class that should be edited inline."""
|
||||
|
||||
"Get the fields in this class that should be edited inline."
|
||||
return [f for f in self.opts.fields + self.opts.many_to_many if f.editable and f != self.field]
|
||||
|
||||
def get_follow(self, override=None):
|
||||
@ -239,7 +239,7 @@ class RelatedObject(object):
|
||||
return "<RelatedObject: %s related to %s>" % ( self.name, self.field.name)
|
||||
|
||||
def get_manipulator_fields(self, opts, manipulator, change, follow):
|
||||
#TODO: remove core fields stuff
|
||||
# TODO: Remove core fields stuff.
|
||||
if change:
|
||||
meth_name = 'get_%s_count' % self.get_method_name_part()
|
||||
count = getattr(manipulator.original_object, meth_name)()
|
||||
@ -256,9 +256,7 @@ class RelatedObject(object):
|
||||
for f in self.opts.fields + self.opts.many_to_many:
|
||||
if follow.get(f.name, False):
|
||||
prefix = '%s.%d.' % (self.var_name, i)
|
||||
fields.extend(
|
||||
f.get_manipulator_fields(self.opts, manipulator, change, name_prefix=prefix, rel=True))
|
||||
|
||||
fields.extend(f.get_manipulator_fields(self.opts, manipulator, change, name_prefix=prefix, rel=True))
|
||||
return fields
|
||||
|
||||
def bind(self, field_mapping, original, bound_related_object_class=BoundRelatedObject):
|
||||
@ -857,11 +855,9 @@ class ModelBase(type):
|
||||
old_app._MODELS[i] = new_class
|
||||
# Replace all relationships to the old class with
|
||||
# relationships to the new one.
|
||||
for related in model._meta.get_all_related_objects() + \
|
||||
model._meta.get_all_related_many_to_many_objects():
|
||||
for related in model._meta.get_all_related_objects() + model._meta.get_all_related_many_to_many_objects():
|
||||
related.field.rel.to = opts
|
||||
break
|
||||
|
||||
return new_class
|
||||
|
||||
class Model:
|
||||
|
Loading…
x
Reference in New Issue
Block a user