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))
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))
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
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))
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)
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
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
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)
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
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)
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())
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)
def detail(): blog_id = int(request.args.get('id')) b = Blog.find(blog_id) return jsonify(b.json())
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)