Opened 3 years ago

Last modified 9 months ago

#21936 assigned New feature

Allow delete to provide a success message through a mixin.

Reported by: david.fischer.ch@… Owned by: Asif Saifuddin Auvi
Component: contrib.messages Version: master
Severity: Normal Keywords: mixin
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

Add a mixin to show a message on successful object deletion.

Attachments (1)

0001-Add-deletemessagemixin.patch (1.2 KB) - added by david.fischer.ch@… 3 years ago.
The patch for this contribution

Download all attachments as: .zip

Change History (18)

Changed 3 years ago by david.fischer.ch@…

The patch for this contribution

comment:1 Changed 3 years ago by AeroNotix

Needs documentation: unset
Needs tests: set
Patch needs improvement: unset

comment:2 Changed 3 years ago by Aymeric Augustin

Needs documentation: set
Patch needs improvement: set
Triage Stage: UnreviewedAccepted
Type: UncategorizedNew feature

Your patch sets the message before the object is deleted. What if deleting the object fails?

Otherwise, this addition makes sense.

comment:3 Changed 2 years ago by Caroline Simpson

Owner: changed from nobody to Caroline Simpson
Status: newassigned

comment:4 Changed 2 years ago by Caroline Simpson

Summary: Add delete message mixinAllow delete to provide a success message through a mixin.

Here is a pull request that approaches the problem from a different angle: https://github.com/django/django/pull/2585
Instead of adding a new mixin, the DeleteView is refactored to allow it to work with the existing SuccessMessageMixin.
Thanks to @charettes for the approach and much of the code.

comment:5 Changed 2 years ago by Caroline Simpson

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset

comment:6 Changed 2 years ago by Baptiste Mispelon

Triage Stage: AcceptedReady for checkin

The approach seems sensible to me and the patch looks quite good.

I'm going to mark this as ready for checkin so that we can get another set of eyes on this in case I've missed something.

Thanks!

comment:7 Changed 2 years ago by Erik Romijn

Patch needs improvement: set
Triage Stage: Ready for checkinAccepted

I see one small issue: the comment on line https://github.com/django/django/pull/2585/files#diff-2b2c9cb35ddf34bc38c90e322dcc39e8L201 still seems valid to me: the documented behaviour has changed, but I don't see a versionchanged annotation, which should be there in a case like this.

comment:8 Changed 2 years ago by Olivier Le Thanh Duong

Bug #21926 was a duplicate of this one.

comment:9 Changed 2 years ago by Caroline Simpson

My main concern with the patch that I have provided is that there are changes related to using the DELETE method for deletions, but it doesn't work entirely as expected. For example, if an application uses a form to verify that a field should be deleted. If the view were to have code that checks that a confirmation box is checked or something similar, and they used the DELETE HTTP method, then the view would not work correctly, as data is not passed through with the request in the case of DELETE. So the documentation change where I changed it to read that you can use DELETE, and a few other changes in the code may not be valid.
There was a comment in the pull request that got buried I think:
"As I was updating the tests, I found that data cannot currently be sent with the DELETE method. When doing further research, I wasn't sure whether this should be allowed or not. The test client accepts a data parameter for DELETE, but the HTTP spec suggests that you shouldn't expect data, like you can for a POST: http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.7 If we want to I can figure out how to actually get data through the chain. Otherwise I can update the documentation to reflect the changes instead."

I wasn't sure how to proceed: to remove the parts related to supporting the DELETE method, or to try to figure out how to get the data through the DELETE chain.

Last edited 2 years ago by Caroline Simpson (previous) (diff)

comment:10 Changed 21 months ago by Caroline Simpson

Patch needs improvement: unset

I've updated the patch with feedback from review.

comment:11 Changed 19 months ago by Asif Saifuddin Auvi

Owner: changed from Caroline Simpson to Asif Saifuddin Auvi

comment:12 Changed 19 months ago by Asif Saifuddin Auvi

new pull request send with moving the conflicting tests.

comment:13 Changed 19 months ago by Erik Romijn

Patch needs improvement: set

Thanks for the new PR. For the record, this is https://github.com/django/django/pull/4256
I left a comment on GitHub regarding the code style issues.

comment:14 Changed 12 months ago by JoseTomasTocino

Is there any status update on this?

comment:15 Changed 12 months ago by Tim Graham

We are waiting for someone to update the pull request as described in comment 13.

comment:16 Changed 12 months ago by Asif Saifuddin Auvi

I will new PR

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