本文整理汇总了Python中models.point.Point.addSupportingPoint方法的典型用法代码示例。如果您正苦于以下问题:Python Point.addSupportingPoint方法的具体用法?Python Point.addSupportingPoint怎么用?Python Point.addSupportingPoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.point.Point
的用法示例。
在下文中一共展示了Point.addSupportingPoint方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from models.point import Point [as 别名]
# 或者: from models.point.Point import addSupportingPoint [as 别名]
def post(self):
jsonOutput = {'result': False}
user = self.current_user
linkType = self.request.get('linkType')
sourcesURLs=json.loads(self.request.get('sourcesURLs'))
sourcesNames=json.loads(self.request.get('sourcesNames'))
parentNewScore = None
if user:
try:
parentPointURL = self.request.get('pointUrl')
oldPoint, oldPointRoot = Point.getCurrentByUrl(parentPointURL)
if oldPointRoot:
newPoint, newLinkPoint = Point.addSupportingPoint(
oldPointRoot=oldPointRoot,
title=self.request.get('title'),
content=self.request.get('content'),
summaryText=self.request.get('plainText'),
user=user,
# backlink=oldPoint.key.parent(),
linkType = linkType,
imageURL=self.request.get('imageURL'),
imageAuthor=self.request.get('imageAuthor'),
imageDescription=self.request.get('imageDescription'),
sourcesURLs=sourcesURLs,
sourcesNames=sourcesNames
)
# TODO: Gene: Probably have a more efficient retrieval here no?
oldPoint, oldPointRoot = Point.getCurrentByUrl(parentPointURL)
if oldPoint:
parentNewScore = oldPoint.pointValue()
else:
raise WhysaurusException('Point with URL %s not found' % parentPointURL)
except WhysaurusException as e:
jsonOutput = {
'result': False,
'errMessage': str(e)
}
else:
ReportEvent.queueEventRecord(user.key.urlsafe(), newLinkPoint.key.urlsafe(), newPoint.key.urlsafe(), "Create Point")
newLinkPointHTML = self.template_render('linkPoint.html', {
'point': newLinkPoint,
'linkType': linkType
})
jsonOutput = {
'result': True,
'version': newPoint.version,
'author': newPoint.authorName,
'dateEdited': newPoint.PSTdateEdited.strftime('%b. %d, %Y, %I:%M %p'),
'numLinkPoints': newPoint.linkCount(linkType),
'newLinkPoint': newLinkPointHTML,
'authorURL': self.current_user.url,
'parentNewScore': parentNewScore
}
self.response.headers["Content-Type"] = 'application/json; charset=utf-8'
self.response.out.write(json.dumps(jsonOutput))
else:
self.response.out.write('Need to be logged in')