Ticket #17962: options.patch

File options.patch, 1.7 KB (added by Chris Wilson, 13 years ago)

Patch to add get_deleted_objects() hook to ModelAdmin

  • django/contrib/admin/options.py

    diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py
    index 73c2958..83246f2 100644
    a b class ModelAdmin(BaseModelAdmin):  
    12511251            'admin/change_list.html'
    12521252        ], context, current_app=self.admin_site.name)
    12531253
     1254    def get_deleted_objects(self, objs, opts, request, using):
     1255        """
     1256        Find all objects related to ``objs`` that should also be deleted. ``objs``
     1257        must be a homogenous iterable of objects (e.g. a QuerySet).
     1258
     1259        Returns a nested list of strings suitable for display in the
     1260        template with the ``unordered_list`` filter.
     1261
     1262        By default this just passes the request on to
     1263        django.contrib.admin.util.get_deleted_objects, but this method exists
     1264        to allow subclasses to override the permissions required to delete
     1265        things.
     1266        """
     1267        return django.contrib.admin.util.get_deleted_objects(objs, opts,
     1268            request.user, self.admin_site, using)
     1269
    12541270    @csrf_protect_m
    12551271    @transaction.commit_on_success
    12561272    def delete_view(self, request, object_id, extra_context=None):
    class ModelAdmin(BaseModelAdmin):  
    12701286
    12711287        # Populate deleted_objects, a data structure of all related objects that
    12721288        # will also be deleted.
    1273         (deleted_objects, perms_needed, protected) = get_deleted_objects(
    1274             [obj], opts, request.user, self.admin_site, using)
     1289        (deleted_objects, perms_needed, protected) = self.get_deleted_objects(
     1290            [obj], opts, request, using)
    12751291
    12761292        if request.POST: # The user has already confirmed the deletion.
    12771293            if perms_needed:
Back to Top