def delete(comment_id): # comment_id = int(request.args.get('id')) t = Comment.find_by(id=comment_id) Comment.check_id(id=comment_id) Comment.remove(comment_id) # 不管如何,都需要返回json的数据,为了触发ajax中回调函数 return jsonify(t.json())
def update(): if Comment.check_token(): form = request.form Comment.check_id(form) newComment = Comment.update(form) # redirect有必要加query吗 return redirect(url_for('tweet.detail', tweet_id=newComment.tweet_id, token=gg.token[current_user().id]))
def update(): token = request.args.get('token') if Comment.check_token(token, gg.csrf_tokens): form = request.form Comment.check_id(form) newTweet = Comment.update(form) # redirect有必要加query吗 return redirect(url_for('tweet.index'))
def update(): form = request.get_json() Comment.check_id(form) newComment = Comment.update(form) return jsonify(newComment.json())
def edit(comment_id): user = current_user() if Comment.check_token(): c = Comment.find(comment_id) Comment.check_id(id=comment_id) return render_template('tweet/comment_edit.html', c=c, token=gg.token[user.id], user=user)
def delete(comment_id): if Comment.check_token(): c = Comment.find(comment_id) Comment.check_id(id=comment_id) c.remove(comment_id) return redirect(url_for('tweet.detail', tweet_id=c.tweet_id, token=gg.token[current_user().id]))