Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#19505 closed Cleanup/optimization (fixed)

Clean up implementation of admin post-save redirects

Reported by: Julien Phalip Owned by: Julien Phalip
Component: contrib.admin Version: 1.4
Severity: Release blocker Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The implementation in 0b908b92a2ca4fb74a103e96bb75c53c05d0a428 to fix #8001 and #18310 introduces some new parameters to ModelAdmin's response_add and response_change methods to control where the user should be redirected after saving an object. One issue with that approach is that it exposes those methods' internal redirection behaviors in their signatures. I think it would be much more flexible to encapsulate those behaviors in a separate method, which could then easily be overridden to provide completely new, custom behaviors. I also think this would make the implementation to fix #6903 easier, although I still need to confirm that (I'm currently working on that ticket, so I should find out soon).

I'm attaching a patch with the suggested new approach. This still needs tests. To apply it, you will first need to revert the original commit, i.e.: git revert 0b908b92a2ca4fb74a103e96bb75c53c05d0a428

I'm marking this ticket as blocker to avoid shipping a new API that I feel a bit uncomfortable with. I'll discuss with Ramiro ASAP to check that this new approach is satisfactory.

Also, note that due to the commit reversion, we're left to deal with the hardcoded url path post_url_continue in the response_add method. I've addressed that in a slightly backwards-incompatible way. Even though we're late in the beta phase, I think we should still move ahead with this BC change since the admin isn't part of the stable API and I'd like to keep the admin's API as clean as possible moving forward. For more details on that, see comments 6 to 12 in #15294.

Attachments (1)

19505.admin-post-save-redirects.diff (4.9 KB ) - added by Julien Phalip 12 years ago.

Download all attachments as: .zip

Change History (7)

by Julien Phalip, 12 years ago

comment:1 by Ramiro Morales <cramm0@…>, 12 years ago

Resolution: fixed
Status: newclosed

In 35d1cd0b28d1d9cd7bffbfbc6cc2e02b58404415:

Fixed #19505 -- A more flexible implementation for customizable admin redirect urls.

Work by Julien Phalip.

Refs #8001, #18310, #19505. See also 0b908b92a2ca4fb74a103e96bb75c53c05d0a428.

comment:2 by Ramiro Morales <cramm0@…>, 12 years ago

In ad769efa85e0296033572315025fed9fa9aefade:

Expanded tests added when fixing #14529.

To make sure changes in 35d1cd0 don't break anything. Refs #19505.

comment:3 by Ramiro Morales <cramm0@…>, 12 years ago

In 3ad34c231bb6e13c29dd268f9557a9cb241280fa:

[1.5.x] Fixed #19505 -- A more flexible implementation for customizable admin redirect urls.

Work by Julien Phalip.

Refs #8001, #18310, #19505. See also 0b908b92a2ca4fb74a103e96bb75c53c05d0a428.

35d1cd0b28d1d9cd7bffbfbc6cc2e02b58404415 from master.

comment:4 by Ramiro Morales <cramm0@…>, 12 years ago

In 3b32e5cc2d4b6db22148cd7e51cdb735aeb25b13:

[1.5.x] Expanded tests added when fixing #14529.

To make sure changes in 35d1cd0 don't break anything. Refs #19505.

ad769efa85e0296033572315025fed9fa9aefade from master.

comment:5 by Julien Phalip <jphalip@…>, 12 years ago

In cee40c7d79930ff42bde4730f43e68a624e47b0f:

Added further flexibility to ModelAdmin for controlling post-save redirections.
Refs #19505.

comment:6 by Julien Phalip <jphalip@…>, 12 years ago

In fa7153612999191323a206b8bf478f6a78d55073:

[1.5.x] Added further flexibility to ModelAdmin for controlling post-save redirections.
Refs #19505.
Backport of cee40c7d79930ff42bde4

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