From 21d6fb6062efa0c81b7e951cf6605bf98a2acd96 Mon Sep 17 00:00:00 2001 From: Carl Meyer Date: Mon, 1 Nov 2010 17:22:13 +0000 Subject: [PATCH] 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 --- django/contrib/admin/actions.py | 2 +- django/contrib/admin/util.py | 20 +++----------------- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/django/contrib/admin/actions.py b/django/contrib/admin/actions.py index 87826be29a..783e1b002d 100644 --- a/django/contrib/admin/actions.py +++ b/django/contrib/admin/actions.py @@ -29,7 +29,7 @@ def delete_selected(modeladmin, request, queryset): # Populate deletable_objects, a data structure of all related objects that # 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. # Do the deletion and return a None to display the change list view again. diff --git a/django/contrib/admin/util.py b/django/contrib/admin/util.py index 00a9a91ead..2056c7c817 100644 --- a/django/contrib/admin/util.py +++ b/django/contrib/admin/util.py @@ -58,21 +58,15 @@ def flatten_fieldsets(fieldsets): field_names.append(field) 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 opts = obj._meta - try: + if has_admin: admin_url = reverse('%s:%s_%s_change' % (admin_site.name, opts.app_label, opts.object_name.lower()), 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, opts.get_delete_permission()) 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), 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 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 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() 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, user=user, admin_site=admin_site, - levels_to_root=levels_to_root, perms_needed=perms_needed) return to_delete, perms_needed