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


Python Team.by_id方法代码示例

本文整理汇总了Python中models.Team.by_id方法的典型用法代码示例。如果您正苦于以下问题:Python Team.by_id方法的具体用法?Python Team.by_id怎么用?Python Team.by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Team的用法示例。


在下文中一共展示了Team.by_id方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: post

# 需要导入模块: from models import Team [as 别名]
# 或者: from models.Team import by_id [as 别名]
 def post(self, *args, **kwargs):
     ''' Called to purchase an item '''
     uuid = self.get_argument('uuid', '')
     item = MarketItem.by_uuid(uuid)
     if not item is None:
         user = self.get_current_user()
         team = Team.by_id(user.team.id)  # Refresh object
         if user.has_item(item.name):
             self.render('market/view.html',
                 user=user,
                 errors=["You have already purchased this item."]
             )
         elif team.money < item.price:
             message = "You only have $%d" % (team.money,)
             self.render('market/view.html', user=user, errors=[message])
         else:
             logging.info("%s (%s) purchased the market item '%s' for $%d" % (
                 user.handle, team.name, item.name, item.price
             ))
             self.purchase_item(team, item)
             event = self.event_manager.create_purchased_item_event(user, item)
             self.new_events.append(event)
             self.redirect('/user/market')
     else:
         self.render('market/view.html',
             user=self.get_current_user(),
             errors=["Item does not exist."]
         )
开发者ID:SYNchroACK,项目名称:RootTheBox,代码行数:30,代码来源:MarketHandlers.py

示例2: award_money

# 需要导入模块: from models import Team [as 别名]
# 或者: from models.Team import by_id [as 别名]
def award_money(box, team, auth):
    ''' Awards money if everything authenticated properly '''
    team = Team.by_id(team.id)  # Refresh object
    if auth.confirmed_access == 'root':
        team.money += box.root_award
    else:
        team.money += box.user_award
    dbsession.add(team)
    dbsession.flush()
开发者ID:brutalhonesty,项目名称:RootTheBox,代码行数:11,代码来源:AuthenticateReporter.py

示例3: to_dict

# 需要导入模块: from models import Team [as 别名]
# 或者: from models.Team import by_id [as 别名]
 def to_dict(self):
     ''' Return public data as dictionary '''
     team = Team.by_id(self.team_id)
     return {
         'uuid': self.uuid,
         'handle': self.handle,
         'account': self.account,
         'hash_algorithm': self.algorithm,
         'team_uuid': team.uuid,
     }
开发者ID:brutalhonesty,项目名称:RootTheBox,代码行数:12,代码来源:User.py

示例4: do_chteam

# 需要导入模块: from models import Team [as 别名]
# 或者: from models.Team import by_id [as 别名]
 def do_chteam(self, username):
     ''' Change team '''
     user = User.by_handle(username)
     if user is None:
         print(WARN + str("%s user not found in database." % username))
     else:
         print(INFO + "Available teams:")
         for team in Team.all():
             print(" %d. %s" % (team.id, team.name))
         team_id = raw_input(PROMPT + "Set user's team to: ")
         team = Team.by_id(team_id)
         if team is not None:
             user.team_id = team.id
             dbsession.add(user)
             dbsession.flush()
             print(INFO + "Successfully changed %s's team to %s." % (
                         user.handle, team.name
                 )
             )
         else:
             print(WARN + "Team does not exist.")
开发者ID:mach327,项目名称:RootTheBox,代码行数:23,代码来源:recovery.py


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