Opened 8 years ago

Closed 8 years ago

#26543 closed Bug (fixed)

Changelist actions don't redirect after failed action resulting in possible ERR_CACHE_MISS in next steps

Reported by: Emmanuelle Delescolle Owned by: Adonys Alea Boffill
Component: contrib.admin Version: 1.9
Severity: Normal Keywords:
Cc: emma@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: yes

Description

When a changlist action fail (at least when failing because no item was selected) no redirect is triggered.
Therefore if the user hits the browser "reload" button, he is asked to confirm that he wants to re-submit the form.
This looks inconsistent where the rest of Django Admin that usually always makes sure the user can hit the refresh button when on a list.

Another use-case where this lead to a more cryptic error message is this one:

  • In a changelist select "Delete selected records" and click go
  • A warning is displayed telling you to select items
  • select any number of records
  • pick "Delete selected records" and click go again
  • On the confirmation page, click "No, take me back"
  • Browser shows an ERR_CACHE_MISS error

Possible fixes I see:

  • update the changelist code to redirect to the same changelist if an error occurs during the execution of a changelist action (fixes both use-cases)
  • update the delete confirmation page to not use the browser history to go back (fixes only problem 2 but might also have some undesired side-effects like loss of selection)

Attachments (1)

#26543.diff (8.8 KB ) - added by Adonys Alea Boffill 8 years ago.
Fixed changelist actions don't redirect after failed action

Download all attachments as: .zip

Change History (11)

comment:1 by Emmanuelle Delescolle, 8 years ago

Cc: emma@… added

comment:2 by Tim Graham, 8 years ago

Triage Stage: UnreviewedAccepted

comment:3 by Adonys Alea Boffill, 8 years ago

Owner: changed from nobody to Adonys Alea Boffill
Status: newassigned

by Adonys Alea Boffill, 8 years ago

Attachment: #26543.diff added

Fixed changelist actions don't redirect after failed action

comment:4 by Adonys Alea Boffill, 8 years ago

Has patch: set

This problem occurs every time that Django admin return again to the page after a failed POST . In other words, every time that the validation of ActionForm is failed. To solve this situation I added the current validations to the JavaScript level, and the rest works fine.

comment:5 by Tim Graham, 8 years ago

Needs tests: set

Thanks for the patch. I haven't taken a close look but a selenium test would also be required. To ease comment on the patch, please send a pull request rather than attaching a patch to ticket. One thing I noticed from a quick glance is that I'm not sure if moving <ul class="messagelist"> outside {% if messages %} is acceptable since that could create an empty <ul> which isn't valid HTML.

comment:6 by Adonys Alea Boffill, 8 years ago

Needs tests: unset

I added the Selenium tests and follow the suggestion of <ul class="messagelist">. This is the pull request https://github.com/django/django/pull/7645 .

Version 0, edited 8 years ago by Adonys Alea Boffill (next)

comment:7 by Tim Graham, 8 years ago

Has patch: unset

As discussed on the pull request, the redirect solution seems fine to me. We prefer writing Python over JavaScript, and I don't think the admin needs to be super slick about this case.

comment:8 by Adonys Alea Boffill, 8 years ago

Thanks for the comment and I'm agree , today I'll make the new pull request with the redirect solution using only python code modification.

comment:9 by Adonys Alea Boffill, 8 years ago

Has patch: set

I added the new pull request with the new solution. To solve this ticket in the new pull request, a redirect will be made every time that Changelist action fail by ActionForm's validation error. This is the reference to the pull request ... https://github.com/django/django/pull/7726

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

Resolution: fixed
Status: assignedclosed

In 8ba01d1:

Fixed #26543 -- Prevented "confirm form submission" browser prompt when reloading after an admin actions failure.

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