Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed #12241 -- Preserved query strings when using "Save and continue/add another" in admin #17194

Merged
merged 1 commit into from Oct 11, 2023

Conversation

marianaasilva
Copy link
Contributor

Fix for ticket 12241 to ensure the query string is preserved when clicking "Save and add another" or "Save and continue"

Added tests for query string with changelist filters

Based on @matthewn's patch pr/16206

Copy link
Contributor

@LilyFoote LilyFoote left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice to see progress on this!

I see that we also have _saveasnew in response_change - is this deliberately handled differently? I see it's bundled with the _continue handling in response_add, so we're changing the behaviour there.

Either way, I think we should add tests for this case too.

@marianaasilva
Copy link
Contributor Author

Nice to see progress on this!

I see that we also have _saveasnew in response_change - is this deliberately handled differently? I see it's bundled with the _continue handling in response_add, so we're changing the behaviour there.

Either way, I think we should add tests for this case too.

@LilyFoote Thank you for the feedback 😄

After looking more closely into this, I believe the _saveasnew condition in response_change is never reached? From what I understood, the response_add and response_change methods get called in _changeform_view but if the request method is a POST and _saveasnew is present in the request data, it will always default to response_add

@LilyFoote
Copy link
Contributor

I think you're right! In that case I think it's reasonable to delete the unreachable code. Though perhaps in a separate PR. @felixxm @nessita Thoughts?

For this PR, I still think we should add a test for preserving the query strings (or explicitly not preserving them) for the _saveasnew option in response_add, since that is reachable if I understand correctly.

@marianaasilva
Copy link
Contributor Author

I think you're right! In that case I think it's reasonable to delete the unreachable code. Though perhaps in a separate PR. @felixxm @nessita Thoughts?

For this PR, I still think we should add a test for preserving the query strings (or explicitly not preserving them) for the _saveasnew option in response_add, since that is reachable if I understand correctly.

Makes sense! Already updated the tests to include the _saveasnew option. Thank you!

Copy link
Contributor

@shangxiao shangxiao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Adding my 2¢ since I looked at the previous PR)

Just tested it out, looks nice 🏆

I didn't really read the code in anger although the only thing that catches my eye is "qsl" which made me wonder what it meant … eventually saw the docs for parse_qsl() as returning list.

@felixxm
Copy link
Member

felixxm commented Sep 27, 2023

@marianaasilva Thanks 👍 Have you checked how it works with options that are currently preserved (_popup, and _to_field)? We should add tests for them, check out #16206 (comment).

tests/admin_views/tests.py Outdated Show resolved Hide resolved
@felixxm felixxm self-assigned this Oct 11, 2023
@felixxm
Copy link
Member

felixxm commented Oct 11, 2023

I think you're right! In that case I think it's reasonable to delete the unreachable code. Though perhaps in a separate PR. @felixxm @nessita Thoughts?

For this PR, I still think we should add a test for preserving the query strings (or explicitly not preserving them) for the _saveasnew option in response_add, since that is reachable if I understand correctly.

Good catch 🎯 Yes we should remove it in a separate PR. @marianaasilva Would you like to prepare it?

…ntinue/add another" in admin.

Co-authored-by: Grady Yu <gradyy@users.noreply.github.com>
Co-authored-by: David Sanders <shang.xiao.sanders@gmail.com>
Co-authored-by: Matthew Newton <matthewn@berkeley.edu>
Copy link
Member

@felixxm felixxm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marianaasilva Thanks 👍

I squashed commits, and simplified tests.

@felixxm felixxm merged commit fc62e17 into django:main Oct 11, 2023
26 checks passed
@marianaasilva marianaasilva deleted the ticket_12241 branch October 16, 2023 12:38
@marianaasilva
Copy link
Contributor Author

I think you're right! In that case I think it's reasonable to delete the unreachable code. Though perhaps in a separate PR. @felixxm @nessita Thoughts?
For this PR, I still think we should add a test for preserving the query strings (or explicitly not preserving them) for the _saveasnew option in response_add, since that is reachable if I understand correctly.

Good catch 🎯 Yes we should remove it in a separate PR. @marianaasilva Would you like to prepare it?

Sure! Working on it 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants