threads.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:BookCloud 作者: livro-aberto 项目源码 文件源码
def deletecomment(project, comment_id):
    comment = Comment.get_by_id(comment_id)
    if comment.has_replies():
        flash(_('This comment has replies and cannot be deleted'), 'error')
    else:
        if not current_user.is_authenticated:
            flash(_('You must be logged in to delete a comment'), 'error')
        else:
            if (current_user != comment.owner
                and current_user != project.get_master().owner):
                flash(_('You are not allowed '
                        'to delete this thread'), 'error')
            else:
                comment.delete()
                db.session.commit()
                flash(_('Comment successfully deleted'), 'info')
    if 'return_url' in request.args:
        return redirect(urllib.unquote(request.args['return_url']))
    else:
        return redirect(url_for('branches.view', project=project.name,
                                branch='master', filename='index'))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号