本文整理汇总了Python中model.Post.get_post_by_id方法的典型用法代码示例。如果您正苦于以下问题:Python Post.get_post_by_id方法的具体用法?Python Post.get_post_by_id怎么用?Python Post.get_post_by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.Post
的用法示例。
在下文中一共展示了Post.get_post_by_id方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from model import Post [as 别名]
# 或者: from model.Post import get_post_by_id [as 别名]
def post(self, postId):
post = Post.get_post_by_id(postId)
if not post or post.status != 0 or post.commentstatus == 1:
self.write('抱歉,评论功能已关闭。')
else:
username = self.get_argument('username', '')
email = self.get_argument('email', '')
content = self.get_argument('comment', '')
parentid = int(self.get_argument('parentid', 0))
if self.islogin:
curr_user_info = self.get_current_user_info
username = curr_user_info.username
email = curr_user_info.email
if username == '' or content == '' or not isemail(email):
self.flash(u'错误:称呼、电子邮件与内容是必填项')
self.redirect(post.url + '#comments')
return
username = username[:20]
content = content[:512]
if not self.islogin:
is_spam = spam_check(content, self.request.remote_ip)
else:
is_spam = 0
if is_spam:
self.flash(u'sorry,your comment is not posted')
self.redirect(post.url+'#comments')
location = get_location_byip(self.request.remote_ip)
Comment.post_comment(postid=postId, username=username, email=email, content=content, parentid=parentid,
ip=self.request.remote_ip, isspam=is_spam, location=location)
if is_spam:
self.flash(u'您的评论可能会被认定为Spam')
self.set_comment_user(username, email)
self.redirect(post.url + '#comments')
示例2: get
# 需要导入模块: from model import Post [as 别名]
# 或者: from model.Post import get_post_by_id [as 别名]
def get(self, id):
post = Post.get_post_by_id(id, ignorestatus=True)
self.datamap['category'] = Category.get_categorys()
self.datamap['tags'] = Tag.get_tags()
self.datamap['post'] = post
self.datamap['chose_tag'] = [x.tag for x in post.tag]
self.datamap['chose_category'] = [x.category for x in post.category]
self.write(render_admin.editpost(self.datamap))
示例3: get
# 需要导入模块: from model import Post [as 别名]
# 或者: from model.Post import get_post_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))