本文整理汇总了Python中models.comment.Comment.get_by_id方法的典型用法代码示例。如果您正苦于以下问题:Python Comment.get_by_id方法的具体用法?Python Comment.get_by_id怎么用?Python Comment.get_by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.comment.Comment
的用法示例。
在下文中一共展示了Comment.get_by_id方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from models.comment import Comment [as 别名]
# 或者: from models.comment.Comment import get_by_id [as 别名]
def post(self):
comment_id = self.request.get('comment_id')
comment_txt = self.request.get('comment')
comment = Comment.get_by_id(int(comment_id))
comment.comment = comment_txt
comment.put()
self.redirect('/blog/%s' % comment.post.key().id())
示例2: post
# 需要导入模块: from models.comment import Comment [as 别名]
# 或者: from models.comment.Comment import get_by_id [as 别名]
def post(self, comment_id):
comment = Comment.get_by_id(int(comment_id))
comment.content = self.request.get("content")
comment.updated = datetime.datetime.now()
comment.updated_by = users.get_current_user().nickname()
comment.put()
self.redirect("/topic/" + str(comment.the_topic_id))
示例3: delete_post_comment
# 需要导入模块: from models.comment import Comment [as 别名]
# 或者: from models.comment.Comment import get_by_id [as 别名]
def delete_post_comment(comment_id):
comment = Comment.get_by_id(comment_id)
origin_post = comment.post.get()
origin_post.num_comments -= 1
origin_post.put()
#will now display [deleted] to keep comment chain intact
comment.partial_delete()
return origin_post.key.id()
示例4: get
# 需要导入模块: from models.comment import Comment [as 别名]
# 或者: from models.comment.Comment import get_by_id [as 别名]
def get(self):
if self.authenticated():
comment_id = self.request.get('comment_id')
comment = Comment.get_by_id(int(comment_id))
if comment.commenter.username == self.user.username:
self.render("edit_comment.html",comment = comment)
else:
self.render_homepage("You can not edit others comment !")
else:
self.login_redirect()
示例5: post
# 需要导入模块: from models.comment import Comment [as 别名]
# 或者: from models.comment.Comment import get_by_id [as 别名]
def post(self):
comment_id = self.request.get('comment_id')
comment = Comment.get_by_id(int(comment_id))
if self.authenticated():
if comment.commenter.username == self.user.username:
comment.delete()
else:
self.render_homepage("You cant delete others comment")
self.redirect('/blog/%s' % comment.post.key().id())
else:
self.login_redirect()
示例6: get
# 需要导入模块: from models.comment import Comment [as 别名]
# 或者: from models.comment.Comment import get_by_id [as 别名]
def get(self, comment_id):
user = users.get_current_user()
comment = Comment.get_by_id(int(comment_id))
if user.nickname() in ADMINS or user.nickname() == comment.author:
args = {}
args["comment_content"] = comment.content
self.base_args(user, args)
self.render_template("edit-comment.html", args)
else:
self.redirect("/topic/" + str(comment.the_topic_id))
示例7: get
# 需要导入模块: from models.comment import Comment [as 别名]
# 或者: from models.comment.Comment import get_by_id [as 别名]
def get(self, id):
comment = Comment.get_by_id(int(id))
if(comment):
author_key = Comment.author.get_value_for_datastore(comment)
author = User.get(author_key)
values = {
"comment": comment,
"author": author,
}
path = "comment/reply.html"
self.render(path, values)
else:
raise GetpitchdError("Comment does not exist.")
示例8: add_comment
# 需要导入模块: from models.comment import Comment [as 别名]
# 或者: from models.comment.Comment import get_by_id [as 别名]
def add_comment(post_id, comment_body, user, parent_id=None):
post = Post.get_by_id(post_id)
if parent_id is not None:
parent = Comment.get_by_id(parent_id).key
comment = Comment()
comment.add(
text=comment_body,
author=user,
post=post.key,
parent=None if parent_id is None else parent)
if post.num_comments is None:
post.num_comments = 0
post.num_comments += 1
post.put()
示例9: post
# 需要导入模块: from models.comment import Comment [as 别名]
# 或者: from models.comment.Comment import get_by_id [as 别名]
def post(self, id):
comment = Comment.get_by_id(int(id))
if(comment):
text = self.request.get("text")
if(text is not ""):
idea_key = Comment.idea.get_value_for_datastore(comment)
idea = Idea.get(idea_key)
reply = Comment(
idea = idea_key,
author = self.current_user.key(),
reply_to = comment.key(),
text = text,
)
reply.put()
idea.comments += 1
idea.put()
event = CommentReplyEvent(self.current_user, reply, comment)
values = {
"response" : "Reply sent",
"next":{
"content": "Back",
"url": "/idea/"+str(idea.key().id())
}
}
path = "feedback.html"
self.render(path, values)
else:
raise GetpitchdError("Comment text is empty")
else:
raise GetpitchdError("Comment does not exist.")
示例10: edit_comment
# 需要导入模块: from models.comment import Comment [as 别名]
# 或者: from models.comment.Comment import get_by_id [as 别名]
def edit_comment(comment_id, new_text):
comment = Comment.get_by_id(comment_id)
comment.comment_text = new_text
comment.put()
示例11: get_single_comment
# 需要导入模块: from models.comment import Comment [as 别名]
# 或者: from models.comment.Comment import get_by_id [as 别名]
def get_single_comment(comment_id):
comment = Comment.get_by_id(comment_id)
return comment
示例12: delete_comment_by_id
# 需要导入模块: from models.comment import Comment [as 别名]
# 或者: from models.comment.Comment import get_by_id [as 别名]
def delete_comment_by_id(id):
c = Comment.get_by_id(id)
if c:
c.delete()