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


Python User.get_by_id方法代码示例

本文整理汇总了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))
开发者ID:erniearl,项目名称:levelblocks,代码行数:49,代码来源:Home.py

示例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))
开发者ID:erniearl,项目名称:levelblocks,代码行数:24,代码来源:Home.py


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