Okay, we don't know that indexes are falsey, so let's make it clearer. Yeek!
[mediagoblin.git] / mediagoblin / db / mixin.py
index 048cc07cae84551e576ee3c0134399946025d02a..1f2e7ec30262d762deab08704059cc15b02bd6f2 100644 (file)
@@ -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__,