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).
This commit is contained in:
Karl Hobley 2016-03-27 18:38:41 +01:00 committed by Nikolay Radchuk
parent d22be01d37
commit db269928e8
3 changed files with 6 additions and 3 deletions

View file

@ -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)

View file

@ -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

View file

@ -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')