# HG changeset patch # User tflorac@xsup98-004.onf.fr # Date 1507840038 -7200 # Node ID 46819098e77a433be4e22b57c26659808cda79f6 # Parent af969d925a91725b0efee0ed3f99898372fd60fb Added thumbnails for external files diff -r af969d925a91 -r 46819098e77a src/pyams_content/component/extfile/__init__.py --- a/src/pyams_content/component/extfile/__init__.py Thu Oct 12 22:26:26 2017 +0200 +++ b/src/pyams_content/component/extfile/__init__.py Thu Oct 12 22:27:18 2017 +0200 @@ -14,6 +14,7 @@ # import standard library +import os # import interfaces from pyams_content.component.association.interfaces import IAssociationInfo @@ -27,6 +28,7 @@ # import packages from pyams_content.component.association import AssociationItem +from pyams_file.file import ImageFile, VideoFile, AudioFile, EXTENSIONS_THUMBNAILS from pyams_i18n.property import I18nFileProperty from pyams_utils.adapter import adapter_config, ContextAdapter from pyams_utils.registry import query_utility @@ -84,7 +86,11 @@ @property def user_title(self): - return II18n(self.context).query_attribute('title') or self.context.filename + name, ext = os.path.splitext(self.context.filename) + return '{title} '.format( + title=II18n(self.context).query_attribute('title') or self.context.filename, + thumb=EXTENSIONS_THUMBNAILS.get(ext, 'unknown.png')) @property def inner_title(self): @@ -124,9 +130,7 @@ extfile.filename = info.filename else: info.filename = extfile.filename - for lang, data in (extfile.data or {}).items(): - if data is not None: - IFileInfo(data).language = lang + info.language = extfile.language @subscriber(IObjectAddedEvent, context_selector=IBaseExtFile) @@ -165,7 +169,7 @@ class ExtFile(BaseExtFile): """Generic external file persistent class""" - icon_class = 'fa-file-o' + icon_class = 'fa-file-text-o' icon_hint = _("Standard file") data = I18nFileProperty(IExtFile['data'])