mirror of
https://github.com/django/django.git
synced 2025-07-04 17:59:13 +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]
|
self.field_mappings = field_mapping[related_object.opts.module_name]
|
||||||
|
|
||||||
def template_name(self):
|
def template_name(self):
|
||||||
raise NotImplementedException
|
raise NotImplementedError
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return repr(self.__dict__)
|
return repr(self.__dict__)
|
||||||
@ -173,24 +173,25 @@ class RelatedObject(object):
|
|||||||
rel_instances = self.get_list(obj)
|
rel_instances = self.get_list(obj)
|
||||||
for i, rel_instance in enumerate(rel_instances):
|
for i, rel_instance in enumerate(rel_instances):
|
||||||
instance_data = {}
|
instance_data = {}
|
||||||
|
|
||||||
for f in self.opts.fields + self.opts.many_to_many:
|
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)
|
fol = follow.get(f.name, None)
|
||||||
if fol:
|
if fol:
|
||||||
field_data = f.flatten_data(fol, rel_instance)
|
field_data = f.flatten_data(fol, rel_instance)
|
||||||
for name, value in field_data.items():
|
for name, value in field_data.items():
|
||||||
instance_data['%s.%d.%s' % (self.var_name, i, name)] = value
|
instance_data['%s.%d.%s' % (self.var_name, i, name)] = value
|
||||||
new_data.update(instance_data)
|
new_data.update(instance_data)
|
||||||
|
|
||||||
return new_data
|
return new_data
|
||||||
|
|
||||||
def extract_data(self, 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
|
return data # TODO
|
||||||
|
|
||||||
def get_list(self, parent_instance=None):
|
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:
|
if parent_instance != None:
|
||||||
func_name = 'get_%s_list' % self.get_method_name_part()
|
func_name = 'get_%s_list' % self.get_method_name_part()
|
||||||
func = getattr(parent_instance, func_name)
|
func = getattr(parent_instance, func_name)
|
||||||
@ -214,8 +215,7 @@ class RelatedObject(object):
|
|||||||
|
|
||||||
|
|
||||||
def editable_fields(self):
|
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]
|
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):
|
def get_follow(self, override=None):
|
||||||
@ -239,7 +239,7 @@ class RelatedObject(object):
|
|||||||
return "<RelatedObject: %s related to %s>" % ( self.name, self.field.name)
|
return "<RelatedObject: %s related to %s>" % ( self.name, self.field.name)
|
||||||
|
|
||||||
def get_manipulator_fields(self, opts, manipulator, change, follow):
|
def get_manipulator_fields(self, opts, manipulator, change, follow):
|
||||||
#TODO: remove core fields stuff
|
# TODO: Remove core fields stuff.
|
||||||
if change:
|
if change:
|
||||||
meth_name = 'get_%s_count' % self.get_method_name_part()
|
meth_name = 'get_%s_count' % self.get_method_name_part()
|
||||||
count = getattr(manipulator.original_object, meth_name)()
|
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:
|
for f in self.opts.fields + self.opts.many_to_many:
|
||||||
if follow.get(f.name, False):
|
if follow.get(f.name, False):
|
||||||
prefix = '%s.%d.' % (self.var_name, i)
|
prefix = '%s.%d.' % (self.var_name, i)
|
||||||
fields.extend(
|
fields.extend(f.get_manipulator_fields(self.opts, manipulator, change, name_prefix=prefix, rel=True))
|
||||||
f.get_manipulator_fields(self.opts, manipulator, change, name_prefix=prefix, rel=True))
|
|
||||||
|
|
||||||
return fields
|
return fields
|
||||||
|
|
||||||
def bind(self, field_mapping, original, bound_related_object_class=BoundRelatedObject):
|
def bind(self, field_mapping, original, bound_related_object_class=BoundRelatedObject):
|
||||||
@ -857,11 +855,9 @@ class ModelBase(type):
|
|||||||
old_app._MODELS[i] = new_class
|
old_app._MODELS[i] = new_class
|
||||||
# Replace all relationships to the old class with
|
# Replace all relationships to the old class with
|
||||||
# relationships to the new one.
|
# relationships to the new one.
|
||||||
for related in model._meta.get_all_related_objects() + \
|
for related in model._meta.get_all_related_objects() + model._meta.get_all_related_many_to_many_objects():
|
||||||
model._meta.get_all_related_many_to_many_objects():
|
|
||||||
related.field.rel.to = opts
|
related.field.rel.to = opts
|
||||||
break
|
break
|
||||||
|
|
||||||
return new_class
|
return new_class
|
||||||
|
|
||||||
class Model:
|
class Model:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user