Пример #1
0
def comment_del(id):  #删除评论
    comment = Comment.query.filter_by(id=id).first()
    user_name = User.query.filter_by(id=comment.user_id).first()
    movie_name = Movie.query.filter_by(id=comment.movie_id).first()
    if Comment.comment_del(id):
        op_log_list = Oplog(
            admin_id=int(session['admin_id']),
            addtime=datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
            ip=request.remote_addr,
            reason="删除 %s 对电影 %s 的评论:%s 成功" %
            (user_name, movie_name, comment.content))
        Oplog.add_log(op_log_list)  #加入日志
        flash('评论删除成功!', 'ok')
        return redirect(url_for('admin.comment_list', page=1))
    return redirect(url_for('admin.comment_list', page=1))