Exemplo n.º 1
0
def comment_update():
    form = request.form.to_dict()
    c_id = form['id']
    Comment.update(form)
    c = Comment.find(c_id)
    b = Blog.find(c.blog_id)
    return redirect(url_for('routes_blog.detail', blog_id=b.id))
Exemplo n.º 2
0
 def f():
     data, u = request_data()
     blog_id = data.get('id')
     b = Blog.find(blog_id)
     if u.id == b.user_id:
         return route_function()
     else:
         return redirect(url_for('routes_blog.detail', blog_id=blog_id))
Exemplo n.º 3
0
def update():
    form = request.form
    blog_id = int(request.args.get('id'))
    item = Blog.find(blog_id)
    if same_user_required(item):
        b = Blog.update(blog_id, form)
        return redirect(url_for('blog.detail', id=blog_id))
    else:
        pass
Exemplo n.º 4
0
 def f():
     data, u = request_data()
     comment_id = data.get('id')
     c = Comment.find(comment_id)
     if u.id == c.user_id:
         return route_function()
     else:
         blog = Blog.find(c.blog_id)
         return redirect(url_for('routes_blog.detail', blog_id=blog.id))
Exemplo n.º 5
0
def edit():
    u = current_user()
    blog_id = request.args.get('id', -1)
    b = Blog.find(blog_id)
    boards = Board.all()
    return render_template('routes_blog/blog_edit.html',
                           blog=b,
                           u=u,
                           boards=boards)
Exemplo n.º 6
0
def edit():
    """
    主页的处理函数, 返回主页的响应
    """
    blog_id = int(request.args.get('id'))
    item = Blog.find(blog_id)
    if same_user_required(item):
        return render_template('blog_edit.html', blog=item)
    else:
        pass
Exemplo n.º 7
0
def delete():
    blog_id = int(request.args.get('id'))
    item = Blog.find(blog_id)
    if same_user_required(item):
        b = Blog.delete(blog_id)
        blogComments = Blogcomment.find_all(blog_id=str(blog_id))
        for bc in blogComments:
            Blogcomment.delete(bc.id)
        return jsonify(b.json())
    else:
        pass
Exemplo n.º 8
0
def detail(blog_id):
    u = current_user()
    b = Blog.find(blog_id)
    Blog.get(blog_id)
    v = b.user()
    token = new_csrf_token()
    return render_template('routes_blog/blog_detail.html',
                           blog=b,
                           u=u,
                           v=v,
                           token=token)
Exemplo n.º 9
0
def blog_comment_recent(v):
    # 拿到reply_list,并翻转
    comment_list = Comment.find_all(user_id=v.id)
    comment_list.reverse()
    # 筛选reply_list的topic_id
    blog_id_list = []
    for i in comment_list:
        if i.blog_id not in blog_id_list:
            blog_id_list.append(i.blog_id)
    # 通过topic_id拿到对应的topic
    blog_list = []
    for i in blog_id_list:
        blog_list.append(Blog.find(i))
    return blog_list
Exemplo n.º 10
0
def view(blog_id):
    comments = BlogComment.find_all(blog_id=blog_id)
    blog = Blog.find(blog_id)
    return render_template("blog/blog_view.html", blog=blog, comments=comments)
Exemplo n.º 11
0
def detail():
    blog_id = int(request.args.get('id'))
    b = Blog.find(blog_id)
    log('load blog detail', b)
    if b is not None:
        return jsonify(b.json())
Exemplo n.º 12
0
def view(blog_id):
    print('inner view ({})'.format(blog_id))
    comments = BlogComment.find_all(blog_id=blog_id)
    blog = Blog.find(blog_id)
    return render_template("blog_view.html", blog=blog, comments=comments)
Exemplo n.º 13
0
def detail():
    blog_id = int(request.args.get('id'))
    b = Blog.find(blog_id)
    return jsonify(b.json())
Exemplo n.º 14
0
def view_blog(blog_id):
    blog = Blog.find(blog_id)
    comments = BlogComment.find_all(blog_id=blog_id)
    return render_template('view_blog.html', blog=blog, comments=comments)