Opened 12 years ago

Closed 6 years ago

#17962 closed New feature (fixed)

Add ModelAdmin.get_deleted_objects() hook

Reported by: Chris Wilson Owned by: Rebecca Smith
Component: contrib.admin Version: dev
Severity: Normal Keywords:
Cc: Chris Wilson, Rebecca Smith Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I want to increase control over who can delete what objects using the admin interface.

delete_view calls has_delete_permission(), which is fine, but then it calls get_deleted_objects() from django.contrib.admin.util.

This is very hard to override without monkey-patching get_deleted_objects(), because it requires replacing the whole of delete_view just to change one line.

I propose calling a member method get_deleted_objects(), which by default just calls the one from util, to make it easy to override this behaviour.

I've attached a patch without tests, because the existing tests should check that this doesn't break anything.

Attachments (1)

options.patch (1.7 KB ) - added by Chris Wilson 12 years ago.
Patch to add get_deleted_objects() hook to ModelAdmin

Download all attachments as: .zip

Change History (11)

by Chris Wilson, 12 years ago

Attachment: options.patch added

Patch to add get_deleted_objects() hook to ModelAdmin

comment:1 by Luke Plant, 12 years ago

Component: Uncategorizedcontrib.admin
Needs documentation: set
Needs tests: set
Triage Stage: UnreviewedAccepted
Type: UncategorizedNew feature

I'm accepting, but marking as 'needs tests', because although it is a simple change, we need tests that check that ModelAdmin.get_deleted_objects() is actually used. This has been our policy with other simple changes, like #14206 for ModelAdmin.get_list_display, and ListView.get_paginator.

comment:2 by Rebecca Smith, 7 years ago

Owner: changed from nobody to Rebecca Smith
Status: newassigned

comment:3 by Rebecca Smith, 7 years ago

Needs documentation: unset
Needs tests: unset

I have added PR #8267 to update the previously submitted patch and use the new ModelAdmin method in the default delete_selected action as well as delete_view.

comment:4 by Tim Graham, 7 years ago

Summary: Django Admin delete_view could benefit from extension pointsAdd ModelAdmin.get_deleted_objects() hook

comment:5 by Tim Graham, 7 years ago

Patch needs improvement: set

I left comments for improvement on the PR. Please uncheck "Patch needs improvement" after updating.

comment:6 by Rebecca Smith, 7 years ago

Cc: Rebecca Smith added
Patch needs improvement: unset

comment:7 by Carlton Gibson, 6 years ago

Triage Stage: AcceptedReady for checkin

comment:8 by Tim Graham, 6 years ago

Patch needs improvement: set
Triage Stage: Ready for checkinAccepted

comment:9 by Carlton Gibson, 6 years ago

Patch needs improvement: unset
Triage Stage: AcceptedReady for checkin

comment:10 by Tim Graham <timograham@…>, 6 years ago

Resolution: fixed
Status: assignedclosed

In 8116e588:

Fixed #17962 -- Added ModelAdmin.get_deleted_objects().

Note: See TracTickets for help on using tickets.
Back to Top