当前位置: 首页>>代码示例>>Python>>正文


Python Comment.get_by_id方法代码示例

本文整理汇总了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())
开发者ID:harikrish00,项目名称:blogit,代码行数:9,代码来源:edit_comment.py

示例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))
开发者ID:KlemenGlobocnik,项目名称:forum,代码行数:10,代码来源:CommentHandlers.py

示例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()
开发者ID:Roasbeef,项目名称:FlaskrNews,代码行数:11,代码来源:api.py

示例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()
开发者ID:harikrish00,项目名称:blogit,代码行数:12,代码来源:edit_comment.py

示例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()
开发者ID:harikrish00,项目名称:blogit,代码行数:13,代码来源:delete_comment.py

示例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))
开发者ID:KlemenGlobocnik,项目名称:forum,代码行数:13,代码来源:CommentHandlers.py

示例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.")
开发者ID:detcherry,项目名称:gopitch,代码行数:18,代码来源:reply.py

示例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()
开发者ID:Roasbeef,项目名称:FlaskrNews,代码行数:20,代码来源:api.py

示例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.")
开发者ID:detcherry,项目名称:gopitch,代码行数:40,代码来源:reply.py

示例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()
开发者ID:Roasbeef,项目名称:FlaskrNews,代码行数:6,代码来源:api.py

示例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
开发者ID:Roasbeef,项目名称:FlaskrNews,代码行数:5,代码来源:api.py

示例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()
开发者ID:ComMouse,项目名称:mukioplayer,代码行数:6,代码来源:tools.py


注:本文中的models.comment.Comment.get_by_id方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。