def get(self, blog_post_url): """Handles GET requests.""" blog_post = blog_services.get_blog_post_by_url_fragment(blog_post_url) if not blog_post: raise self.PageNotFoundException( Exception( 'The blog post page with the given url doesn\'t exist.')) user_settings = user_services.get_user_settings(blog_post.author_id) blog_post_dict = ( blog_services.get_blog_post_from_model(blog_post).to_dict()) blog_post_dict['author_name'] = user_settings.username del blog_post_dict['author_id'] blog_post_summaries = ( blog_services.get_published_blog_post_summaries_by_user_id( blog_post.author_id, feconf.MAX_POSTS_TO_RECOMMEND_AT_END_OF_BLOG_POST)) blog_post_summary_dicts = ( _get_blog_card_summary_dicts_for_homepage(blog_post_summaries)) self.values.update({ 'profile_picture_data_url': user_settings.profile_picture_data_url, 'blog_post_dict': blog_post_dict, 'summary_dicts': blog_post_summary_dicts }) self.render_json(self.values)
def test_get_blog_post_from_model(self): blog_post_model = blog_models.BlogPostModel.get(self.blog_post_a_id) blog_post = blog_services.get_blog_post_from_model(blog_post_model) self.assertEqual(blog_post.to_dict(), self.blog_post_a.to_dict())