Removed dead compatibility code for removed AdminSite.root() method for mounting admin urls.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@14412 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Carl Meyer 2010-11-01 17:22:13 +00:00
parent 5c05233ffc
commit 21d6fb6062
2 changed files with 4 additions and 18 deletions

View File

@ -29,7 +29,7 @@ def delete_selected(modeladmin, request, queryset):
# Populate deletable_objects, a data structure of all related objects that # Populate deletable_objects, a data structure of all related objects that
# will also be deleted. # will also be deleted.
deletable_objects, perms_needed = get_deleted_objects(queryset, opts, request.user, modeladmin.admin_site, levels_to_root=2) deletable_objects, perms_needed = get_deleted_objects(queryset, opts, request.user, modeladmin.admin_site)
# The user has already confirmed the deletion. # The user has already confirmed the deletion.
# Do the deletion and return a None to display the change list view again. # Do the deletion and return a None to display the change list view again.

View File

@ -58,21 +58,15 @@ def flatten_fieldsets(fieldsets):
field_names.append(field) field_names.append(field)
return field_names return field_names
def _format_callback(obj, user, admin_site, levels_to_root, perms_needed): def _format_callback(obj, user, admin_site, perms_needed):
has_admin = obj.__class__ in admin_site._registry has_admin = obj.__class__ in admin_site._registry
opts = obj._meta opts = obj._meta
try: if has_admin:
admin_url = reverse('%s:%s_%s_change' admin_url = reverse('%s:%s_%s_change'
% (admin_site.name, % (admin_site.name,
opts.app_label, opts.app_label,
opts.object_name.lower()), opts.object_name.lower()),
None, (quote(obj._get_pk_val()),)) None, (quote(obj._get_pk_val()),))
except NoReverseMatch:
admin_url = '%s%s/%s/%s/' % ('../'*levels_to_root,
opts.app_label,
opts.object_name.lower(),
quote(obj._get_pk_val()))
if has_admin:
p = '%s.%s' % (opts.app_label, p = '%s.%s' % (opts.app_label,
opts.get_delete_permission()) opts.get_delete_permission())
if not user.has_perm(p): if not user.has_perm(p):
@ -88,7 +82,7 @@ def _format_callback(obj, user, admin_site, levels_to_root, perms_needed):
return u'%s: %s' % (capfirst(opts.verbose_name), return u'%s: %s' % (capfirst(opts.verbose_name),
force_unicode(obj)) force_unicode(obj))
def get_deleted_objects(objs, opts, user, admin_site, levels_to_root=4): def get_deleted_objects(objs, opts, user, admin_site):
""" """
Find all objects related to ``objs`` that should also be Find all objects related to ``objs`` that should also be
deleted. ``objs`` should be an iterable of objects. deleted. ``objs`` should be an iterable of objects.
@ -96,13 +90,6 @@ def get_deleted_objects(objs, opts, user, admin_site, levels_to_root=4):
Returns a nested list of strings suitable for display in the Returns a nested list of strings suitable for display in the
template with the ``unordered_list`` filter. template with the ``unordered_list`` filter.
`levels_to_root` defines the number of directories (../) to reach
the admin root path. In a change_view this is 4, in a change_list
view 2.
This is for backwards compatibility since the options.delete_selected
method uses this function also from a change_list view.
This will not be used if we can reverse the URL.
""" """
collector = NestedObjects() collector = NestedObjects()
for obj in objs: for obj in objs:
@ -114,7 +101,6 @@ def get_deleted_objects(objs, opts, user, admin_site, levels_to_root=4):
to_delete = collector.nested(_format_callback, to_delete = collector.nested(_format_callback,
user=user, user=user,
admin_site=admin_site, admin_site=admin_site,
levels_to_root=levels_to_root,
perms_needed=perms_needed) perms_needed=perms_needed)
return to_delete, perms_needed return to_delete, perms_needed