From db269928e8f09e2a0c646224a3fdaafd3049b22f Mon Sep 17 00:00:00 2001 From: Karl Hobley Date: Sun, 27 Mar 2016 18:38:41 +0100 Subject: [PATCH] Set explorer menu media with property instead of class Fixes #2369 The static() function was being called during app load which caused a crash when the user is using STATICFILES_STORAGE=ManifestStaticFilesStorage, DEBUG=False and haven't yet collected static files. I've moved it into a property and it's now only called when a view is being rendered. This also is more consistent because we usually set media using properties (and so does Django admin). --- CHANGELOG.txt | 1 + docs/releases/1.4.2.rst | 2 +- wagtail/wagtailadmin/wagtail_hooks.py | 6 ++++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 25016ba3d..0b6ae69a8 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -7,6 +7,7 @@ Changelog * Fix: Streamfields no longer break on validation error * Fix: Number of validation errors in each tab in the editor is now correctly reported again * Fix: Userbar now opens on devices with both touch and mouse (Josh Barr) + * Fix: ``wagtail.wagtailadmin.wagtail_hooks`` no longer calls ``static`` during app load, so you can use ``ManifestStaticFilesStorage`` without calling ``collectstatic`` command 1.4.1 (17.03.2016) diff --git a/docs/releases/1.4.2.rst b/docs/releases/1.4.2.rst index dc5ae18b7..4bc426d0c 100644 --- a/docs/releases/1.4.2.rst +++ b/docs/releases/1.4.2.rst @@ -16,4 +16,4 @@ Bug fixes * Streamfields no longer break on validation error * Number of validation errors in each tab in the editor is now correctly reported again * Userbar now opens on devices with both touch and mouse (Josh Barr) - + * ``wagtail.wagtailadmin.wagtail_hooks`` no longer calls ``static`` during app load, so you can use ``ManifestStaticFilesStorage`` without calling ``collectstatic`` command diff --git a/wagtail/wagtailadmin/wagtail_hooks.py b/wagtail/wagtailadmin/wagtail_hooks.py index 52049a788..eebf28c15 100644 --- a/wagtail/wagtailadmin/wagtail_hooks.py +++ b/wagtail/wagtailadmin/wagtail_hooks.py @@ -1,3 +1,4 @@ +from django import forms from django.core import urlresolvers from django.contrib.auth.models import Permission from django.utils.translation import ugettext_lazy as _ @@ -10,8 +11,9 @@ from wagtail.wagtailadmin.search import SearchArea class ExplorerMenuItem(MenuItem): - class Media: - js = [static('wagtailadmin/js/explorer-menu.js')] + @property + def media(self): + return forms.Media(js=[static('wagtailadmin/js/explorer-menu.js')]) @hooks.register('register_admin_menu_item')