From eaad01308142337739d7edd9f08bd8e714be23f0 Mon Sep 17 00:00:00 2001 From: Matt Westcott Date: Fri, 26 Apr 2019 16:40:58 +0100 Subject: [PATCH] Output form media on add/edit/chooser image forms with custom models * Add tests for custom image on multiple image uploader * Output form media on image add/edit views * Output form media for 'add image' form within image chooser modal Note: this won't work reliably if the media is hosted on a CDN, because script tags inserted as part of a jQuery DOM insertion (as modals are) are loaded asynchronously and not guaranteed to complete loading before inline scripts are run. It's better than not having the includes there at all though... --- CHANGELOG.txt | 1 + docs/releases/2.7.rst | 1 + .../wagtailimages/chooser/chooser.html | 3 + .../templates/wagtailimages/images/add.html | 7 + .../templates/wagtailimages/images/edit.html | 4 + .../templates/wagtailimages/multiple/add.html | 4 + wagtail/images/tests/test_admin_views.py | 191 ++++++++++++++++++ wagtail/images/tests/tests.py | 1 + wagtail/images/views/multiple.py | 19 +- .../tests/testapp/migrations/0001_initial.py | 5 +- wagtail/tests/testapp/models.py | 6 +- 11 files changed, 230 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index c8447c7d9..a202d5973 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -17,6 +17,7 @@ Changelog * Fix: Default text of page links in rich text uses the public page title rather than the admin display title (Andy Chosak) * Fix: Specific page permission checks are now enforced when viewing a page revision (Andy Chosak) * Fix: `pageurl` and `slugurl` tags no longer fail when `request.site` is `None` (Samir Shah) + * Fix: Output form media on add/edit image forms with custom models (Matt Westcott) 2.6.1 (05.08.2019) diff --git a/docs/releases/2.7.rst b/docs/releases/2.7.rst index fdaede9b5..e312e6fc2 100644 --- a/docs/releases/2.7.rst +++ b/docs/releases/2.7.rst @@ -35,6 +35,7 @@ Bug fixes * Default text of page links in rich text uses the public page title rather than the admin display title (Andy Chosak) * Specific page permission checks are now enforced when viewing a page revision (Andy Chosak) * ``pageurl`` and ``slugurl`` tags no longer fail when ``request.site`` is ``None`` (Samir Shah) + * Output form media on add/edit image forms with custom models (Matt Westcott) Upgrade considerations diff --git a/wagtail/images/templates/wagtailimages/chooser/chooser.html b/wagtail/images/templates/wagtailimages/chooser/chooser.html index d60ddd72f..ca80787a9 100644 --- a/wagtail/images/templates/wagtailimages/chooser/chooser.html +++ b/wagtail/images/templates/wagtailimages/chooser/chooser.html @@ -3,6 +3,9 @@ {% trans "Choose an image" as choose_str %} {% include "wagtailadmin/shared/header.html" with title=choose_str merged=1 tabbed=1 icon="image" %} +{{ uploadform.media.js }} +{{ uploadform.media.css }} + {% if uploadform %}