diff options
author | Boris Bobrov <breton@cynicmansion.ru> | 2014-08-16 02:18:12 +0300 |
---|---|---|
committer | Boris Bobrov <breton@cynicmansion.ru> | 2016-02-05 05:30:28 +0300 |
commit | 654d7cf94f41e6b6c01fe021a977d3898e6829a9 (patch) | |
tree | eed22776c7183eb0b7a01082502a4680ca476dec /mediagoblin/db/mixin.py | |
parent | 3b6b009077955c94e76cd2248e16a32dde1d90cf (diff) | |
download | mediagoblin-654d7cf94f41e6b6c01fe021a977d3898e6829a9.tar.lz mediagoblin-654d7cf94f41e6b6c01fe021a977d3898e6829a9.tar.xz mediagoblin-654d7cf94f41e6b6c01fe021a977d3898e6829a9.zip |
Display type icon in thumbnails
Diffstat (limited to 'mediagoblin/db/mixin.py')
-rw-r--r-- | mediagoblin/db/mixin.py | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/mediagoblin/db/mixin.py b/mediagoblin/db/mixin.py index ecd04874..083617d3 100644 --- a/mediagoblin/db/mixin.py +++ b/mediagoblin/db/mixin.py @@ -301,6 +301,15 @@ class MediaEntryMixin(GenerateSlugMixin, GeneratePublicIDMixin): self.media_files[u"original"] ) + @property + def icon_url(self): + '''Return the icon URL (for usage in templates) if it exists''' + try: + return self._app.staticdirector( + self.media_manager['type_icon']) + except AttributeError: + return None + @cached_property def media_manager(self): """Returns the MEDIA_MANAGER of the media's media_type @@ -449,7 +458,7 @@ class CollectionMixin(GenerateSlugMixin, GeneratePublicIDMixin): """ Adds an object to the collection """ # It's here to prevent cyclic imports from mediagoblin.db.models import CollectionItem - + # Need the ID of this collection for this so check we've got one. self.save(commit=False) @@ -457,16 +466,16 @@ class CollectionMixin(GenerateSlugMixin, GeneratePublicIDMixin): item = CollectionItem() item.collection = self.id item.get_object = obj - + if content is not None: item.note = content self.num_items = self.num_items + 1 - + # Save both! self.save(commit=commit) item.save(commit=commit) - return item + return item class CollectionItemMixin(object): @property |