Negligible refactoring in django.core.meta.fields and django.contrib.admin.views.main. Taken from #1020. Refs #1020
git-svn-id: http://code.djangoproject.com/svn/django/trunk@1591 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
f60d4eec38
commit
800cac7e31
|
@ -552,11 +552,11 @@ def _get_deleted_objects(deleted_objects, perms_needed, user, obj, opts, current
|
|||
nh = _nest_help # Bind to local variable for performance
|
||||
if current_depth > 16:
|
||||
return # Avoid recursing too deep.
|
||||
objects_seen = []
|
||||
opts_seen = []
|
||||
for related in opts.get_all_related_objects():
|
||||
if related.opts in objects_seen:
|
||||
if related.opts in opts_seen:
|
||||
continue
|
||||
objects_seen.append(related.opts)
|
||||
opts_seen.append(related.opts)
|
||||
rel_opts_name = related.get_method_name_part()
|
||||
if isinstance(related.field.rel, meta.OneToOne):
|
||||
try:
|
||||
|
@ -600,9 +600,9 @@ def _get_deleted_objects(deleted_objects, perms_needed, user, obj, opts, current
|
|||
if not user.has_perm(p):
|
||||
perms_needed.add(rel_opts.verbose_name)
|
||||
for related in opts.get_all_related_many_to_many_objects():
|
||||
if related.opts in objects_seen:
|
||||
if related.opts in opts_seen:
|
||||
continue
|
||||
objects_seen.append(related.opts)
|
||||
opts_seen.append(related.opts)
|
||||
rel_opts_name = related.get_method_name_part()
|
||||
has_related_objs = False
|
||||
for sub_obj in getattr(obj, 'get_%s_list' % rel_opts_name)():
|
||||
|
|
|
@ -518,10 +518,11 @@ class FileField(Field):
|
|||
def save_file(self, new_data, new_object, original_object, change, rel):
|
||||
upload_field_name = self.get_manipulator_field_names('')[0]
|
||||
if new_data.get(upload_field_name, False):
|
||||
func = getattr(new_object, 'save_%s_file' % self.name)
|
||||
if rel:
|
||||
getattr(new_object, 'save_%s_file' % self.name)(new_data[upload_field_name][0]["filename"], new_data[upload_field_name][0]["content"])
|
||||
func(new_data[upload_field_name][0]["filename"], new_data[upload_field_name][0]["content"])
|
||||
else:
|
||||
getattr(new_object, 'save_%s_file' % self.name)(new_data[upload_field_name]["filename"], new_data[upload_field_name]["content"])
|
||||
func(new_data[upload_field_name]["filename"], new_data[upload_field_name]["content"])
|
||||
|
||||
def get_directory_name(self):
|
||||
return os.path.normpath(datetime.datetime.now().strftime(self.upload_to))
|
||||
|
|
Loading…
Reference in New Issue