Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#25903 closed Bug (fixed)

"Add another" related field buttons in list_editable don't open a popup

Reported by: Federico Curzel Owned by: Tim Graham
Component: contrib.admin Version: 1.9
Severity: Release blocker Keywords: modeladmin popup
Cc: rm_ Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I am referring to the popups you can use to creare a new record on-the-fly while editing an other record.
After upgrade from Django 1.7 to 1.9 those popups aren't opening a popup in the web browser anymore, instead, the page will change, allowing to create a new record.
After saving, a page saying "Closing Popup" will appear, but the page won't go back to the original one.

Attachments (1)

djadmintest.zip (5.4 KB ) - added by Andrey Kolomoets 9 years ago.

Download all attachments as: .zip

Change History (18)

comment:1 by Tim Graham, 9 years ago

Possibly you have some cached JavaScript in your browser? Could you try clearing your cache and also check the JavaScript console of your browser for any errors?

comment:2 by Tim Graham, 9 years ago

Summary: ModelAdmin popups wont'closeModelAdmin popups won't close
Type: UncategorizedBug

comment:3 by Federico Curzel, 9 years ago

Sorry for not doing this before.
In the "Popup Closing..." page there is a JS error.

Chrome :
Uncaught TypeError: Cannot read property 'dismissAddRelatedObjectPopup' of null

Firefox :
TypeError: opener is null

comment:4 by Tim Graham, 9 years ago

Are you using any third-party apps that might be interfering?

comment:5 by Federico Curzel, 9 years ago

Third Party applications are django object actions, django rest framework and django wpadmin.
http://www.django-rest-framework.org/
https://github.com/barszczmm/django-wpadmin
https://github.com/crccheck/django-object-actions

But the likely culprit is django wpadmin, which I forked long ago, and used with Django 1.7.
After upgrading to Django 1.9, Django WpAdmin had some issues, but I thought I fixed everything.
If the error is not replicable by anyone, this might be the cause.

comment:6 by Tim Graham, 9 years ago

Resolution: worksforme
Status: newclosed

Okay, it works for me -- so I'll close this for now. If you can reproduce without those other apps, please reopen.

comment:7 by Andrey Kolomoets, 9 years ago

Resolution: worksforme
Status: closednew

Same here without those apps. Function showAdminPopup is called from change_form.html template but not from change_list.html. So from change_form popup is opened correctly, but in change_list it's just a link without js events.

comment:8 by Tim Graham, 9 years ago

Could you please be more specific with a sample project and/or steps to reproduce?

by Andrey Kolomoets, 9 years ago

Attachment: djadmintest.zip added

in reply to:  8 comment:9 by Andrey Kolomoets, 9 years ago

Replying to timgraham:

Could you please be more specific with a sample project and/or steps to reproduce?

Sorry, forgot to mention that i'm using custom ModelAdmin with list_editable field.
In attachment you can find sample project to reproduce the bug:

  1. Create new Product. In the product creation form click on "Add another category" will popup new window as expected.
  2. Navigate to /admin/products/product/. Click on "Add another category" near the product category will not open popup.
Version 0, edited 9 years ago by Andrey Kolomoets (next)

comment:10 by Tim Graham, 9 years ago

Severity: NormalRelease blocker
Summary: ModelAdmin popups won't close"Add another" related field buttons in list_editable don't open a popup
Triage Stage: UnreviewedAccepted

comment:11 by Tim Graham, 9 years ago

Cc: rm_ added

Hi Riccardo, do you have time to help with this regression from your patch? I guess we're missing test coverage for this case.

comment:12 by Tim Graham, 9 years ago

Owner: changed from nobody to Tim Graham
Status: newassigned

comment:13 by rm_, 9 years ago

Ah missed the previous email sorry. Don't have time atm to cook a patch but from a quick look it looks like that indeed moving django/contrib/admin/static/admin/js/related-widget-wrapper.js content from a separatated file to change_form.html broke popup handling outside of that template. So the change list template needs lines 90-108 from change_form.html and django/contrib/admin/static/admin/js/admin/RelatedObjectLookups.js included to work. We can move that 18 lines to a separate js if we don't want to duplicate them i suppose.

comment:14 by Tim Graham, 9 years ago

Has patch: set

PR for the stable/1.9.x branch (will do a separate one for master since it's not a clean forwardport).

comment:15 by Simon Charette, 9 years ago

Triage Stage: AcceptedReady for checkin

Submited patch against 1.9 looks good to me.

I didn't even know this button showed up in an editable changelist and could have broken it myself when I refactored this part of the admin to add edit/delete buttons.

comment:16 by Tim Graham <timograham@…>, 9 years ago

Resolution: fixed
Status: assignedclosed

In f18b087:

Fixed #25903 -- Fixed the admin's list_editable add/change buttons.

comment:17 by Tim Graham <timograham@…>, 9 years ago

In c80d85d:

[1.9.x] Fixed #25903 -- Fixed the admin's list_editable add/change buttons.

Backport of f18b08748abaecb171fdcbcdfdcd7e4d95d931d1 from master

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