Write function get_blog_by_blogpost
authorAditi <aditi.iitr@gmail.com>
Fri, 9 Aug 2013 09:13:05 +0000 (14:43 +0530)
committerAditi <aditi.iitr@gmail.com>
Fri, 9 Aug 2013 09:13:05 +0000 (14:43 +0530)
mediagoblin/media_types/blog/__init__.py

index cb113ec091fa1c72e52094683ecfd5207e381ea9..ec6f68ec10b3cfe165e70c34a0924d0590a953d2 100644 (file)
@@ -19,6 +19,7 @@ import logging
 _log = logging.getLogger(__name__)
 
 from mediagoblin.media_types import MediaManagerBase
+from mediagoblin.media_types.blog.models import Blog, BlogPostData
 
 from mediagoblin.tools import pluginapi
 
@@ -76,6 +77,11 @@ class BlogPostMediaManager(MediaManagerBase):
     display_template = "mediagoblin/media_displays/blogpost.html"
     default_thumb = "images/media_thumbs/blogpost.jpg"
     
+    def get_blog_by_blogpost(self):
+        blog_post_data = BlogPostData.query.filter_by(media_entry=self.entry.id).first()
+        blog = Blog.query.filter_by(id=blog_post_data.blog).first()
+        return blog
+        
 def get_media_type_and_manager():
         return MEDIA_TYPE, BlogPostMediaManager