Skip to content

Commit

Permalink
Merge pull request #785 from divio/issue/static-call-on-missing-icons
Browse files Browse the repository at this point in the history
Missing icons in 'static()' calls
  • Loading branch information
mikek committed Apr 1, 2016
2 parents a5722d0 + 0f40d24 commit 0254372
Show file tree
Hide file tree
Showing 36 changed files with 27 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ CHANGELOG
* Testrunner cleanup
* Fix many regressions and bugs in Django 1.8/1.9
* Admin UI enhancements
* Fix issues with non-default STATICFILES_STORAGE
* Hide related widget wrapper links
* Fix cancel link in delete confirmation
* Make BaseImage.subject_location field non-nullable
* Adds icon sizes


1.1.1 (2016-01-27)
Expand Down
12 changes: 10 additions & 2 deletions filer/models/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ def icons(self):
r = {}
if getattr(self, '_icon', False):
for size in FILER_ADMIN_ICON_SIZES:
r[size] = static("filer/icons/%s_%sx%s.png" % (
self._icon, size, size))
try:
r[size] = static("filer/icons/%s_%sx%s.png" % (
self._icon, size, size))
except ValueError:
# Do not raise an exception while trying to call static()
# on non-existent icon file. This avoids the issue with
# rendering parts of the template as empty blocks that
# happens on an attempt to access object 'icons' attribute
# in template.
pass
return r
2 changes: 1 addition & 1 deletion filer/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

FILER_PAGINATE_BY = getattr(settings, 'FILER_PAGINATE_BY', 20)

_ICON_SIZES = getattr(settings, 'FILER_ADMIN_ICON_SIZES', ('32', '48', '64'))
_ICON_SIZES = getattr(settings, 'FILER_ADMIN_ICON_SIZES', ('16', '32', '48', '64'))
if not _ICON_SIZES:
raise ImproperlyConfigured('Please, configure FILER_ADMIN_ICON_SIZES')
# Reliably sort by integer value, but keep icon size as string.
Expand Down
Binary file modified filer/static/filer/icons/file_128x128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added filer/static/filer/icons/file_16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added filer/static/filer/icons/file_256x256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified filer/static/filer/icons/file_32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified filer/static/filer/icons/file_48x48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified filer/static/filer/icons/file_64x64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added filer/static/filer/icons/image_16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added filer/static/filer/icons/missingfile_128x128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added filer/static/filer/icons/missingfile_16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added filer/static/filer/icons/missingfile_256x256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added filer/static/filer/icons/missingfile_64x64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added filer/static/filer/icons/nofile_128x128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added filer/static/filer/icons/nofile_16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added filer/static/filer/icons/nofile_256x256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified filer/static/filer/icons/nofile_48x48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added filer/static/filer/icons/nofile_64x64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added filer/static/filer/icons/plainfolder_16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added filer/static/filer/icons/plainfolder_256x256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added filer/static/filer/icons/unfiled_folder_16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added filer/static/filer/icons/video_128x128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added filer/static/filer/icons/video_16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added filer/static/filer/icons/video_64x64.png
Binary file added filer/static/filer/icons/xfile_128x128.png
Binary file added filer/static/filer/icons/xfile_16x16.png
Binary file added filer/static/filer/icons/xfile_256x256.png
Binary file added filer/static/filer/icons/xfile_48x48.png
Binary file added filer/static/filer/icons/xfile_512x512.png
Binary file added filer/static/filer/icons/xfile_64x64.png
14 changes: 14 additions & 0 deletions filer/tests/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from ..models.filemodels import File
from ..models.foldermodels import Folder
from ..models.imagemodels import Image
from ..models.mixins import IconsMixin
from ..test_utils import ET_2
from .helpers import (
create_clipboard_item,
Expand Down Expand Up @@ -107,6 +108,19 @@ def test_create_icons(self):
self.assertEqual(os.path.basename(icons[size]),
file_basename + '__%sx%s_q85_crop_subsampling-2_upscale.jpg' % (size, size))

def test_access_icons_property(self):
"""Test IconsMixin that calls static on a non-existent file"""

class CustomObj(IconsMixin, object):
_icon = 'custom'

custom_obj = CustomObj()
try:
icons = custom_obj.icons
except Exception as e:
self.fail("'.icons' access raised Exception {0} unexpectedly!".format(e))
self.assertEqual(len(icons), len(filer_settings.FILER_ADMIN_ICON_SIZES))

def test_file_upload_public_destination(self):
"""
Test where an image `is_public` == True is uploaded.
Expand Down

0 comments on commit 0254372

Please sign in to comment.