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


Python Notification.create_notification_for_comment_and_user方法代码示例

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


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

示例1: post

# 需要导入模块: from models import Notification [as 别名]
# 或者: from models.Notification import create_notification_for_comment_and_user [as 别名]
  def post(self, post_id):
    session = get_current_session()
    if session.has_key('user'):
      message = helper.sanitizeHtml(self.request.get('message'))
      user = session['user']
      key = self.request.get('comment_key')
      if len(message) > 0 and key == keys.comment_key:
        try:
          post = Post.all().filter('nice_url =', helper.parse_post_id( post_id ) ).get()
          if post  == None: #If for some reason the post doesn't have a nice url, we try the id. This is also the case of all old stories
            post = db.get( helper.parse_post_id( post_id ) ) 

          post.remove_from_memcache()
          comment = Comment(message=message,user=user,post=post)
          comment.put()
          helper.killmetrics("Comment","Root", "posted", session, "",self)
          vote = Vote(user=user, comment=comment, target_user=user)
          vote.put()
          Notification.create_notification_for_comment_and_user(comment,post.user)
          self.redirect('/noticia/' + post_id)
        except db.BadKeyError:
          self.redirect('/')
      else:
        self.redirect('/noticia/' + post_id)
    else:
      self.redirect('/login')
开发者ID:grillermo,项目名称:Noticias-HAcker,代码行数:28,代码来源:PostHandler.py

示例2: post

# 需要导入模块: from models import Notification [as 别名]
# 或者: from models.Notification import create_notification_for_comment_and_user [as 别名]
 def post(self,comment_id):
   session = get_current_session()
   if session.has_key('user'):
     message = helper.sanitizeHtml(self.request.get('message'))
     user = session['user']
     if len(message) > 0:
       try:
         parentComment = db.get(comment_id)
         comment = Comment(message=message,user=user,post=parentComment.post, father=parentComment)
         comment.put()
         comment.post.remove_from_memcache()
         vote = Vote(user=user, comment=comment, target_user=user)
         vote.put()
         Notification.create_notification_for_comment_and_user(comment,parentComment.user)
         self.redirect('/noticia/' + str(parentComment.post.key()))
       except db.BadKeyError:
         self.redirect('/')
     else:
       self.redirect('/responder/' + comment_id)
   else:
     self.redirect('/login')
开发者ID:mantus,项目名称:Noticias-HAcker,代码行数:23,代码来源:main.py


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