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

Fix admin images with Django 1.9 and multi usage of file picker widget #670

Merged
merged 7 commits into from Feb 24, 2016

Conversation

acatton
Copy link
Contributor

@acatton acatton commented Jan 6, 2016

This pull request is kind of a melting pot. I just wanted to fix the static files in the admin center for Django 1.9. But I ended up cleaning up some code as well, and fixing some other things.

Edit: I would strongly advised to review each commit one by one instead of reviewing the whole thing.

@joshuajonah
Copy link

+1

@mkoistinen
Copy link
Contributor

@acatton This looks like great stuff, thanks. What is the current status of this PR?

@Flight
Copy link
Contributor

Flight commented Jan 27, 2016

FE LGTM

@mkoistinen mkoistinen removed this from the 1.1.1 milestone Jan 27, 2016
@mkoistinen
Copy link
Contributor

@acatton Also, can you rebase this against latest develop please?

@acatton
Copy link
Contributor Author

acatton commented Jan 27, 2016

@mkoistinen, @julianandrews or @gavinwahl is supposed to take over this pull request.

@julianandrews
Copy link
Contributor

@mkoistinen, @Flight I've cherry picked the relevant commits from #683 and rebased this PR on top of develop. I decided to make some minor changes to the logic from 3f7e610 to mesh better with the createDropzone function @acatton made, but other than that, to the best of my ability this is just a straightforward rebase of the changes in this PR and #683.

@gavinwahl
Copy link
Contributor

Hey @mkoistinen -- this was rebased a couple weeks ago, but now changes to develop have broken again. This is the 3rd or 4th time we've had to do this. Can we get some kind of confirmation that this will be merged immediately if we do it again?

Thanks

win.close();
};
})(django.jQuery);
<<<<<<< HEAD
Copy link
Contributor

Choose a reason for hiding this comment

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

Here is left a line from merging.

@stefanfoulis stefanfoulis added this to the 1.2.0 milestone Feb 23, 2016
@stefanfoulis stefanfoulis changed the title Fix admin images with Django 1.9 Fix admin images with Django 1.9 and multi usage of file picker widget Feb 23, 2016
@stefanfoulis
Copy link
Contributor

@acatton @julianandrews this PR is awesome and fixes much more than the title indicates. I took the liberty to change the title and updated the description to reflect everything it fixes. I'd like to merge it asap. I you rebase it again, I'll merge it right away. If you don't have time I'll try to tackle the rebase tomorrow morning (CET).
Thanks for the awesome work @acatton and sorry it took us so long to get it merged.

sidenote: does the js refactor happen to also address #736 (clash is other widgets on the same page use jQuery)?

@acatton
Copy link
Contributor Author

acatton commented Feb 23, 2016

@stefanfoulis full disclosure, I left the company and the project that was extensively using this. I was hoping to start my new job with this pull request being merged, but it didn't work out 😉 . This is why I might have been a little passive aggressive in my comments towards the end. And I would like to apologize for this 😅 . No worries, @julianandrews took over the project in question and this pull request as well.

I see that julian merged the two pull requests. I didn't do that because I felt that they were unrelated work, even though #683 was based on this. But julian's the boss now.

What this does is making the javascript a lot more robust. It's difficult to explain, but it is relying on the structure on the page more than on some internal state held in a javascript variable. To answer your question, @julianandrews would have to test it (because I don't have the setup to test it anymore) but it could very likely also fix #736. But i wouldn't like to set these expectations too high.

@stefanfoulis
Copy link
Contributor

@acatton thanks for the quick response. Hopefully @julianandrews can do the rebase. If not, that fine as well and I'll give it a shot. Anyhow, the help of everyone involved is much appreciated 👍 🏆

acatton and others added 7 commits February 23, 2016 13:29
Explicit is better than implicit. LTE_DJANGO_1_9 was added.

Rebased by Julian Andrews <jandrews@fusionbox.com>. If something's
broken, it's probably his fault!
Rebased by Julian Andrews <jandrews@fusionbox.com>. If something's
broken, it's probably his fault!
This code was fragile. A HashedFilenameFileStorage for example would have
broken it.

Rebased by Julian Andrews <jandrews@fusionbox.com>. If something's
broken, it's probably his fault!
This was breaking git's diff
This fixes two bugs:

  * The error message "Dropzone already attached" when having multiple
    FileField on one admin page.
  * Supporting FileField in inlines in Admin.
  * Make the javascript less fragile

These are the changes:

  * Don't use prefixed id, but relative object with classes.
  * Use django.jQuery for everything
  * Remove the useless closures, by replacing:
        (function ($) { $(function () { ... } }(jQuery)
    with:
        jQuery(function ($) { ... })
  * Remove bad practices:
      * $elem.removeAttr('value') -> $elem.val('')
      * var func = ...; $elem.off(event, func); // It was just created
  * Remove bad flow. (Was sometimes using hide(), on other time
    addClass('hidden'))
@julianandrews
Copy link
Contributor

I think this should do it. This at least seems to fix #683. I'm not sure if it addresses #736.

#743 seems to be unfixed; I'm not sure if that's somehow the result of the rebase. I have a good idea at this point how to go about fixing #743, so I'll take a look, but if possible I'd rather get this PR merged in, and I'll submit a much smaller PR if I come up with a good fix.

@julianandrews
Copy link
Contributor

@stefanfoulis

Ignore my last comment about #743. This does fix #743. Somehow I had a cached copy of admin/js/inlines.js in my browser that wasn't creating the appropriate event. This should just work!

@stefanfoulis
Copy link
Contributor

awesome @julianandrews . Thank you very much for the quick response and rebase. It's late at night here, so I'll postpone the review and merge to tomorrow morning.

stefanfoulis added a commit that referenced this pull request Feb 24, 2016
Fix admin images with Django 1.9 and multi usage of file picker widget
@stefanfoulis stefanfoulis merged commit f49bc62 into django-cms:develop Feb 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants