-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Deleting form submission redirects to first listing page #12007
Comments
This has to do with the fact that the submission delete view defines the success URL as https://github.com/wagtail/wagtail/blob/main/wagtail/contrib/forms/views.py#L112-L114 Also the submission list uses bulk actions for the deletion, and the form takes us directly to the deletion view without a |
I'll take a whack at this, at sprint:Arnhem2024 |
@khalidSafwany and I confirmed the bug, and that the fix by @bruecksen works, and his test passes in two separate dev environments so we think his fix is ready to merge. |
Thanks all for reporting, working on the fix, and testing it. Cross-posting my thoughts from the Wagtail Slack: The problem with the proposed solution is that, if you delete a number of submissions in a way that causes the pagination number to no longer exist, you'll be redirected to a 404 page instead of the listing. For example, if you have 21 submissions, and you go to the second page and delete the only submission there, you'll get this: It's a behaviour from Django's While we technically can make it so that out-of-range pagination would just render the closest-available page, that sounds a bit like "magic". Thinking in a more general approach, perhaps the need to "redirect to the page where you were on" wouldn't be that necessary if we had the ability to jump to a specific page (#12004)... As the reporter @tbrlpld, do you have any suggestions on how this specific case should be handled? |
Thanks for investigating this thoroughly @laymonage. That is a valid case, but I think the behavior you describe (to fall back to the new last page) would be sensible. I was under the impression that that's actually how the Django Paginator works already 🤔 maybe I am mistaken about that. |
Ok just checked. https://docs.djangoproject.com/en/5.0/ref/paginator/#django.core.paginator.Paginator.get_page From a user perspective, this also feels the most sensible, as the new page (and thus the items you see) are the closest to what you saw before. |
@laymonage @tbrlpld thanks for you input. Should I add a fix then to return to the last page for out-of-range page numbers? |
That sounds good to me, but I would defer to @laymonage for the core team perspective. |
Unfortunately this method isn't actually used by Django in their We previously had such an override in Wagtail, but it was removed in 8e106f4 since we thought there was no clear reason why we had to do it. A year later, this issue demonstrates why we had that override 😄 I've discussed this with @gasman and we're happy to reinstate the use of So, to proceed with this, we have a few options:
I think I'd be happy with reverting 8e106f4. It may not be straightforward to revert though, as we've made significant changes to the listing views code since then. Happy to provide additional help if needed! |
Does this also apply to the fact that you are redirected to the first page of the listing after editing a page? |
Do you mean in the page tree? Or at a Viewset? (I don't know if that is different) In the bakery demo I could reproduce this in the Bread Ingredient list, editing one ingredient on the second page you end up at the first page. @laymonage any thoughts on this? Should this be handled in this issue as well? If you do this in the page tree you also always end up at the first page but it is always sorted by updated desc, so you see the edited one at the top. I guess that is the intended behaviour there? |
@laymonage yes I guess I need some pointers in the right direction. I added the If I then run the tests, lots of existing tests all over the place ( Thank you! |
@bruecksen Thanks! Yes, I think
The commit also included changes to those tests, so if we revert those changes as well, I think they should pass. |
Issue Summary
When you delete a form submission (on a later pagination page) then after confirming, you are redirected to the first pagination page.
Steps to Reproduce
Any other relevant information. For example, why do you consider this a bug and what did you expect to happen instead?
Technical details
Working on this
Anyone can contribute to this. View our contributing guidelines, add a comment to the issue once you’re ready to start.
This could be a good first issue. Can probably be solved with a
next
parameter or similar on the delete confirm view and using the "current URL" as next on the listing page showing the delete action.The text was updated successfully, but these errors were encountered: