示例#1
0
文件: app.py 项目: tuncutku/Courses
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)
示例#2
0
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())
示例#3
0
    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)
示例#4
0
 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)
示例#5
0
    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)
示例#6
0
 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']))
示例#7
0
 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