def posts(blog_id): blog = Blog.get_blog(blog_id) posts = blog.get_posts() return render_template("posts.html", posts=posts, blog_title=blog.title, blog_id=blog.id)
def get_blog(username, user_blog_id): try: user_blog_id = int(user_blog_id) except ValueError: raise ArgsError('Require {} type {}, but found {}'.format("user_blog_id", int, type(user_blog_id))) blog = Blog.get_blog(username, user_blog_id) return jsonify(blog.to_json())
def get(self, blog_id): data = { 'title': 'blog | detail', 'blog': Blog.get_blog(blog_id), 'all_tag': BlogTags.get_all_tags(), 'all_category': BlogCategory.get_all_category(), } self.render('purecss_ui/blog_detail.html', **data)
def get(self, blog_id): blog = Blog.get_blog(blog_id) data = { 'title': '修改 | 博客', 'blog': blog, 'tags': BlogTags.get_all_tags(), 'category': BlogCategory.get_all_category() } self.render('admin/admin_blog_modify.html', **data)
def _view_blog(self): blog_id = input('Enter ID of the blog you want to read ') blog = Blog.get_blog(blog_id) posts = blog.get_posts() for post in posts: print('Title: {} ' 'Date: {} ' 'Content: {}'.format(post['title'], post['date'], post['content']))
def _user_has_account(self): blog = Database.find_one(collection='blogs', query={'author': self.user}) print('user_data', blog) if blog is None: return False else: self.user_blog = Blog.get_blog(blog['id']) return True