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).
pull/2404/merge
Karl Hobley 2016-03-27 18:38:41 +01:00 zatwierdzone przez Nikolay Radchuk
rodzic 5a6afd32f2
commit dcc89ce9b1
3 zmienionych plików z 6 dodań i 3 usunięć

Wyświetl plik

@ -19,6 +19,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)

Wyświetl plik

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

Wyświetl plik

@ -1,3 +1,4 @@
from django import forms
from django.contrib.auth.models import Permission
from django.contrib.staticfiles.templatetags.staticfiles import static
from django.core.urlresolvers import reverse
@ -11,8 +12,9 @@ from wagtail.wagtailcore.permissions import collection_permission_policy
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')