diff options
Diffstat (limited to 'mediagoblin/db/mixin.py')
-rw-r--r-- | mediagoblin/db/mixin.py | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/mediagoblin/db/mixin.py b/mediagoblin/db/mixin.py index 048cc07c..1f2e7ec3 100644 --- a/mediagoblin/db/mixin.py +++ b/mediagoblin/db/mixin.py @@ -202,6 +202,17 @@ class MediaEntryMixin(GenerateSlugMixin): thumb_url = mg_globals.app.staticdirector(manager[u'default_thumb']) return thumb_url + @property + def original_url(self): + """ Returns the URL for the original image + will return self.thumb_url if original url doesn't exist""" + if u"original" not in self.media_files: + return self.thumb_url + + return mg_globals.app.public_store.file_url( + self.media_files[u"original"] + ) + @cached_property def media_manager(self): """Returns the MEDIA_MANAGER of the media's media_type @@ -248,7 +259,7 @@ class MediaEntryMixin(GenerateSlugMixin): if 'Image DateTimeOriginal' in exif_all: # format date taken - takendate = datetime.datetime.strptime( + takendate = datetime.strptime( exif_all['Image DateTimeOriginal']['printable'], '%Y:%m:%d %H:%M:%S').date() taken = takendate.strftime('%B %d %Y') @@ -294,6 +305,13 @@ class MediaCommentMixin(object): """ return cleaned_markdown_conversion(self.content) + def __unicode__(self): + return u'<{klass} #{id} {author} "{comment}">'.format( + klass=self.__class__.__name__, + id=self.id, + author=self.get_author, + comment=self.content) + def __repr__(self): return '<{klass} #{id} {author} "{comment}">'.format( klass=self.__class__.__name__, |