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


Python Comment.recipient方法代码示例

本文整理汇总了Python中models.Comment.recipient方法的典型用法代码示例。如果您正苦于以下问题:Python Comment.recipient方法的具体用法?Python Comment.recipient怎么用?Python Comment.recipient使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Comment的用法示例。


在下文中一共展示了Comment.recipient方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: post

# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import recipient [as 别名]
  def post(self, forum_id, post_reference):
    user = self.user_model
    post = ForumPost.query(ForumPost.forum_name == forum_id, ForumPost.reference == post_reference).get()
    text = cgi.escape(self.request.get('text'))
    sender = cgi.escape(self.request.get('sender'))
    recipient = cgi.escape(self.request.get('recipient'))
    replied_to_urlsafe = cgi.escape(self.request.get('parent'))
    comment = Comment(parent = post.key)
    if len(replied_to_urlsafe) != 0:
      replied_to_key = ndb.Key(urlsafe=replied_to_urlsafe)
      parent_comment = replied_to_key.get()
      comment.parent = replied_to_key
      comment.offset = parent_comment.offset + 20
      recipient_comment = ndb.Key(urlsafe=replied_to_urlsafe).get()
      comment.recipient = recipient_comment.sender
      comment.sender = user.username
      comment.root = False
    else:
      comment.sender = sender
      comment.recipient = recipient

    comment.text = text
    comment.time = datetime.datetime.now() - datetime.timedelta(hours=7) #For PST
    comment.put()

    if comment.root == False:
      parent_comment.children.append(comment.key)
      parent_comment.put()
      
    post.comment_count += 1
    post.put()
    self.redirect('/tech/{}/{}'.format(forum_id, post_reference))
开发者ID:nikko0327,项目名称:Ninja-Tutor,代码行数:34,代码来源:Forum.py

示例2: post

# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import recipient [as 别名]
  def post(self):
    origin = cgi.escape(self.request.get('origin'))
    text = cgi.escape(self.request.get('text'))
    sender = cgi.escape(self.request.get('sender'))
    recipient = cgi.escape(self.request.get('recipient'))
    replied_to_urlsafe = cgi.escape(self.request.get('parent'))
    viewer = self.user_model
    comment = Comment()
    if len(replied_to_urlsafe) != 0:
      replied_to_key = ndb.Key(urlsafe=replied_to_urlsafe)
      parent_comment = replied_to_key.get() #parent comment
      comment.parent = replied_to_key
      comment.offset = parent_comment.offset + 20
      recipient_comment = ndb.Key(urlsafe=replied_to_urlsafe).get()
      comment.recipient = recipient_comment.sender
      comment.sender = viewer.username
      comment.root = False
    else:
      comment.sender = sender
      comment.recipient = recipient

    # Not double adding User Keys
    if sender != recipient:
      comment.sender_key = User.query(User.username == sender).get().key
      comment.recipient_key = User.query(User.username== recipient).get().key
    else:
      comment.sender_key = User.query(User.username == sender).get().key
      comment.recipient_key = None
    comment.text = text
    comment.time = datetime.datetime.now() - datetime.timedelta(hours=8) #For PST
    comment.put()
    
    if comment.root == False:
      parent_comment.children.append(comment.key)
      parent_comment.put()

    self.redirect('/profile/{}'.format(recipient))
开发者ID:nikko0327,项目名称:Ninja-Tutor,代码行数:39,代码来源:Feed.py


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