本文整理汇总了Python中model.User.User.get_by_id方法的典型用法代码示例。如果您正苦于以下问题:Python User.get_by_id方法的具体用法?Python User.get_by_id怎么用?Python User.get_by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.User.User
的用法示例。
在下文中一共展示了User.get_by_id方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from model.User import User [as 别名]
# 或者: from model.User.User import get_by_id [as 别名]
def post(self, levelid=""):
user = User.getLevelBlockUser(users.get_current_user())
currentlevel = Level.getById(int(levelid))
action = self.request.get('done')
if user:
if action == 'true':
self.response.headers['Content-Type'] = 'application/json'
#check to see if level belongs to user and is if published
if currentlevel.user.id == user.key.id:
if not currentlevel.published:
currentlevel.published = True
currentlevel.played += 1
currentlevel.put()
else:
user.score += 1
user.put()
self.response.out.write('{"points": 1, "publish": true}')
else:
score = 0
if currentlevel.jackpot:
score = math.ceil(currentlevel.score * 0.5)
creator = User.get_by_id(currentlevel.user.id())
creator.score += int(score)
creator.put()
currentlevel.jackpot = False
currentlevel.played += 1
currentlevel.put()
else:
score += math.ceil(currentlevel.score * 0.1)
user.score += int(score)
user.put()
self.response.out.write('{"points": ' + str(score) + ', "publish": false}')
else:
if currentlevel.published:
if currentlevel.jackpot:
currentlevel.score += 1
currentlevel.played += 1
currentlevel.put()
else:
template_values = {
'signinurl' : users.create_login_url("/")
}
template = jinja_environment.get_template('signin.html')
self.response.out.write(template.render(template_values))
示例2: get
# 需要导入模块: from model.User import User [as 别名]
# 或者: from model.User.User import get_by_id [as 别名]
def get(self, levelid=""):
user = User.getLevelBlockUser(users.get_current_user())
#checks to see if we have a user signed in
if user:
currentlevel = Level.getById(int(levelid))
creator = User.get_by_id(currentlevel.user.id())
template_values = {
'level': currentlevel,
'creator': creator
}
template = jinja_environment.get_template('game.html')
self.response.out.write(template.render(template_values))
#if not is ask them to sign in
else:
template_values = {
'signinurl' : users.create_login_url("/")
}
template = jinja_environment.get_template('signin.html')
self.response.out.write(template.render(template_values))