本文整理汇总了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')
示例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')