def api_delete_subcomment(comment_id, own_id):
'''
delete a subcomment from a certain comment
'''
if not g.__user__.get('admin'):
return make_response('Permission denied.', 403)
db.comments.update_one(
{'_id': ObjectId(comment_id)},
{
'$pull': {'subcontent': {'_id': own_id}}
})
if not db.comments.find_one({'_id': ObjectId(comment_id)}).get('subcontent'):
db.comments.update_one(
{'_id': ObjectId(comment_id)},
{
'$set': {'subcomment': False}
})
blog_id = db.comments.find_one({'_id': ObjectId(comment_id)}).get('blog_id')
return redirect(url_for('api.api_get_blog_comments', blog_id=blog_id))
评论列表
文章目录