本文整理汇总了Python中models.Post.find_by_id方法的典型用法代码示例。如果您正苦于以下问题:Python Post.find_by_id方法的具体用法?Python Post.find_by_id怎么用?Python Post.find_by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Post
的用法示例。
在下文中一共展示了Post.find_by_id方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: status
# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import find_by_id [as 别名]
def status(name, id):
post = Post.find_by_id(id)
if post:
if post.user.username == name:
return render_template('single.html', header='page', username=post.user.username, tweet=post, page='single.html', logged=user_is_logged())
abort(404)
示例2: delete
# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import find_by_id [as 别名]
def delete(user, id):
post = Post.find_by_id(id)
if post:
Post.delete(user,id)
return redirect('/home')
else:
abort(404)
示例3: comment_page
# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import find_by_id [as 别名]
def comment_page(post_id):
user_id = session.get('user_id')
if user_id:
post = Post.find_by_id(post_id)
return render_template('comment_post.html', post = post,user_id=user_id)
else:
return redirect(url_for('index'))
示例4: get
# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import find_by_id [as 别名]
def get(self, path):
if not self.user:
self.redirect('/login')
post_id = self.request.get('id')
if post_id and post_id.isdigit():
post = Post.find_by_id(post_id=int(post_id), path=path)
if not post:
self.abort(404)
else:
post = Post.find_by_path(path=path).get()
self.render("edit_post.html", path=path, post=post)
示例5: show_post
# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import find_by_id [as 别名]
def show_post(post_id):
# Check login status
post = Post.find_by_id(post_id)
# Search all the comments related.
comments = Post.retrieve_comments(post_id)
likes = Post.retrieve_likes(post_id)
if post:
self_id = session.get('user_id')
if self_id:
me_like = any(r.u['id'] == self_id for r in likes)
else:
me_like = False
poster = Post.find_poster(post_id)
return render_template('post_page.html', post=post, poster=poster.one, comments=comments, likes=likes, me_like=me_like)
else:
return redirect(url_for('index'))