本文整理汇总了Python中model.Comment.delete_comment_by_id方法的典型用法代码示例。如果您正苦于以下问题:Python Comment.delete_comment_by_id方法的具体用法?Python Comment.delete_comment_by_id怎么用?Python Comment.delete_comment_by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.Comment
的用法示例。
在下文中一共展示了Comment.delete_comment_by_id方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from model import Comment [as 别名]
# 或者: from model.Comment import delete_comment_by_id [as 别名]
def get(self):
page = int(self.get_argument('page', 1))
if self.get_argument('act', '') == 'delete':
Comment.delete_comment_by_id(int(self.get_argument('id', 0)))
pagesize = 20
rtn = Comment.get_comments(pagesize=pagesize)
self.datamap['comments'] = rtn[1]
self.datamap['count'] = rtn[0]
self.datamap['pagecount'] = int(math.ceil(float(rtn[0]) / pagesize))
self.write(render_admin.comment(self.datamap))
示例2: get
# 需要导入模块: from model import Comment [as 别名]
# 或者: from model.Comment import delete_comment_by_id [as 别名]
def get(self, postId):
post = None
act = self.get_argument('act', '')
if act == 'del_comment' and self.islogin:
cid = self.get_argument('cid', 0)
Comment.delete_comment_by_id(cid)
self.add_header('content-type', 'application/json;charset=utf-8')
self.write(json.dumps({'code': 0, 'msg': 'OK'}))
return
if isint(postId):
post = Post.get_post_by_id(postId, ignorestatus=True)
else:
post = Post.get_post_by_alias(postId, ignorestatus=True)
if not post or post.status != 0:
self.set_error(404)
act = self.get_argument('act', '')
if act == 'clear':
self.set_secure_cookie('post_' + str(postId), '', expires_days=-10)
self.datamap['valid'] = True
if post.password.strip() != "":
if self.get_secure_cookie('post_' + str(postId)) != post.password:
self.datamap['valid'] = False
if act and self.islogin:
if act == 'delete':
Post.delete_post_by_id(postId)
self.redirect('/')
return
elif act == 'edit':
self.redirect('/admin/?url=/admin/post/edit/%s/' % post.id)
return
self.datamap['post'] = post
self.datamap['recent'] = Post.get_recent_post()
comment = Comment.get_comments_by_postid(post.id, isAdmin=self.islogin)
self.datamap['commentcount'] = comment[0]
self.datamap['comments'] = comment[1]
if self.islogin:
self.datamap['curr_user_info'] = self.get_current_user_info
self.write(render.post(self.datamap))