本文整理匯總了Python中models.point.Point.addNotificationTask方法的典型用法代碼示例。如果您正苦於以下問題:Python Point.addNotificationTask方法的具體用法?Python Point.addNotificationTask怎麽用?Python Point.addNotificationTask使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類models.point.Point
的用法示例。
在下文中一共展示了Point.addNotificationTask方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: saveComment
# 需要導入模塊: from models.point import Point [as 別名]
# 或者: from models.point.Point import addNotificationTask [as 別名]
def saveComment(self):
results = {'result': False}
text = self.request.get('commentText')
pointRootUrlsafe = self.request.get('p')
parentCommentUrlsafe = self.request.get('parentKey')
user = self.current_user
if user:
try:
pointRoot = PointRoot.getByUrlsafe(pointRootUrlsafe)
if pointRoot:
comment = Comment.create(
text, user, pointRoot,
parentCommentUrlsafe)
if comment:
pst_date = PST.convert(comment.date)
results = {
'result': True,
'userName': user.name,
'userURL': user.url,
'avatar_url': user.avatar_url if hasattr(user, 'avatar_url') else '/static/img/icon_triceratops_black_47px.png',
'text': text,
'date': pst_date.strftime('%b. %d, %Y, %I:%M %p'),
'parentUrlsafe': parentCommentUrlsafe,
'myUrlSafe':comment.key.urlsafe(),
'level': comment.level
}
Point.addNotificationTask(pointRoot.key, user.key, 3, text)
else:
results['error'] = 'Unable to find the point to add this comment'
except WhysaurusException as e:
results['error'] = str(e)
resultJSON = json.dumps(results)
self.response.headers["Content-Type"] = 'application/json; charset=utf-8'
self.response.out.write(resultJSON)