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


Python Team.by_uuid方法代码示例

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


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

示例1: team_details

# 需要导入模块: from models.Team import Team [as 别名]
# 或者: from models.Team.Team import by_uuid [as 别名]
 def team_details(self):
     print self.get_argument('uuid', '')
     team = Team.by_uuid(self.get_argument('uuid', ''))
     if team is not None:
         self.write(team.to_dict())
     else:
         self.write({})
开发者ID:WeiEast,项目名称:RootTheBox,代码行数:9,代码来源:AdminUserHandlers.py

示例2: edit_team

# 需要导入模块: from models.Team import Team [as 别名]
# 或者: from models.Team.Team import by_uuid [as 别名]
 def edit_team(self):
     ''' Edits the team object '''
     try:
         team = Team.by_uuid(self.get_argument('uuid', ''))
         if team is None:
             raise ValidationError("Team does not exist")
         team.name = self.get_argument('name', team.name)
         team.motto = self.get_argument('motto', team.motto)
         team.money = self.get_argument('money', team.money)
         self.dbsession.add(team)
         self.dbsession.commit()
         self.redirect('/admin/users')
     except ValidationError as error:
         self.render('admin/view/users.html',
                     errors=[str(error), ]
                     )
开发者ID:WeiEast,项目名称:RootTheBox,代码行数:18,代码来源:AdminUserHandlers.py

示例3: edit_user

# 需要导入模块: from models.Team import Team [as 别名]
# 或者: from models.Team.Team import by_uuid [as 别名]
 def edit_user(self):
     ''' Update user objects in the database '''
     try:
         user = User.by_uuid(self.get_argument('uuid', ''))
         if user is None:
             raise ValidationError("User does not exist")
         handle = self.get_argument('handle', '')
         if user.handle != handle:
             if User.by_handle(handle) is None:
                 logging.info("Updated user handle %s -> %s" % (
                     user.handle, handle
                 ))
                 user.handle = handle
             else:
                 raise ValidationError("Handle is already in use")
         hash_algorithm = self.get_argument('hash_algorithm', '')
         if hash_algorithm != user.algorithm:
             if hash_algorithm in user.algorithms:
                 if 0 < len(self.get_argument('bank_password', '')):
                     logging.info("Updated %s's hashing algorithm %s -> %s" % (
                         user.handle, user.algorithm, hash_algorithm,
                     ))
                     user.algorithm = hash_algorithm
                 else:
                     raise ValidationError(
                         "You must provide a new bank password when updating the hashing algorithm")
             else:
                 raise ValidationError("Not a valid hash algorithm")
         user.password = self.get_argument('password', '')
         if len(self.get_argument('bank_password', '')):
             user.bank_password = self.get_argument('bank_password', '')
         team = Team.by_uuid(self.get_argument('team_uuid', ''))
         if team is not None:
             if user not in team.members:
                 logging.info("Updated %s's team %s -> %s" % (
                     user.handle, user.team_id, team.name
                 ))
                 user.team_id = team.id
         else:
             raise ValidationError("Team does not exist in database")
         self.dbsession.add(user)
         self.dbsession.commit()
         self.redirect('/admin/users')
     except ValidationError as error:
         self.render("admin/view/users.html",
                     errors=[str(error), ]
                     )
开发者ID:WeiEast,项目名称:RootTheBox,代码行数:49,代码来源:AdminUserHandlers.py

示例4: edit_teams

# 需要导入模块: from models.Team import Team [as 别名]
# 或者: from models.Team.Team import by_uuid [as 别名]
 def edit_teams(self):
     ''' Edit existing team objects in the database '''
     team = Team.by_uuid(self.get_argument('uuid', ''))
     if team is not None:
         try:
             name = self.get_argument('name', '')
             if team.name != name:
                 logging.info("Updated team name %s -> %s" % (team.name, name))
                 team.name = name
             motto = self.get_argument('motto', '')
             if team.motto != motto:
                 logging.info("Updated %s's motto %s -> %s" % (team.name, team.motto, motto))
                 team.motto = motto
             self.dbsession.add(team)
             self.dbsession.close()
             self.redirect("/admin/view/user_objects")
         except ValueError as error:
             self.render("admin/view/user_objects.html", errors=["%s" % error])
     else:
         self.render("admin/view/user_objects.html", errors=["Team does not exist"])
开发者ID:AdaFormacion,项目名称:RootTheBox,代码行数:22,代码来源:AdminHandlers.py

示例5: team_details

# 需要导入模块: from models.Team import Team [as 别名]
# 或者: from models.Team.Team import by_uuid [as 别名]
 def team_details(self):
     ''' Returns team details in JSON form '''
     uuid = self.get_argument('uuid', '')
     team = Team.by_uuid(uuid)
     if team is not None:
         details = {
             'name': team.name,
             'game_levels': [],
         }
         for lvl in team.levels:
             lvl_details = {
                 'number': lvl.number,
                 'captured':
                     [flag.name for flag in team.level_flags(lvl.number)],
                 'total': len(lvl.flags),
             }
             details['game_levels'].append(lvl_details)
         self.write(details)
     else:
         self.write({'error': 'Team does not exist'})
     self.finish()
开发者ID:AnarKyx01,项目名称:RootTheBox,代码行数:23,代码来源:ScoreboardHandlers.py

示例6: del_team

# 需要导入模块: from models.Team import Team [as 别名]
# 或者: from models.Team.Team import by_uuid [as 别名]
 def del_team(self):
     '''
     Delete team objects in the database.
     '''
     team = Team.by_uuid(self.get_argument('uuid', ''))
     for user in team.members:
         if user == self.get_current_user():
             self.render("admin/view/users.html",
                     errors=["Unable to delete user %s" % user.handle]
                     )
             return
     if team is not None:
         logging.info("Deleted Team: '%s'" % str(team.name))
         self.dbsession.delete(team)
         self.dbsession.commit()
         self.flush_memcached()
         self.redirect("/admin/users")
     else:
         self.render("admin/view/users.html",
                     errors=["Team does not exist"]
                     )
开发者ID:moloch--,项目名称:RootTheBox,代码行数:23,代码来源:AdminUserHandlers.py

示例7: post

# 需要导入模块: from models.Team import Team [as 别名]
# 或者: from models.Team.Team import by_uuid [as 别名]
 def post(self, *args, **kwargs):
     try:
         group = self.get_argument('team_uuid', 'all')
         message = self.get_argument('message', '')
         value = int(self.get_argument('money', 0))
         if group == 'all':
             teams = Team.all()
             for team in teams:
                 team.money += value
                 self.dbsession.add(team)
                 self.event_manager.admin_score_update(team, message, value)
         else:
             team = Team.by_uuid(group)
             team.money += value
             self.dbsession.add(team)
             self.event_manager.admin_score_update(team, message, value)
         self.dbsession.commit()
         self.redirect('/admin/users')
     except ValidationError as error:
         self.render('admin/view/users.html',
                     errors=[str(error), ]
                     )
开发者ID:moloch--,项目名称:RootTheBox,代码行数:24,代码来源:AdminUserHandlers.py

示例8: edit_team

# 需要导入模块: from models.Team import Team [as 别名]
# 或者: from models.Team.Team import by_uuid [as 别名]
 def edit_team(self):
     ''' Edits the team object '''
     try:
         team = Team.by_uuid(self.get_argument('uuid', ''))
         if team is None:
             raise ValidationError("Team does not exist")
         team.name = self.get_argument('name', team.name)
         team.motto = self.get_argument('motto', team.motto)
         team.money = self.get_argument('money', team.money)
         if hasattr(self.request, 'files') and 'avatarfile' in self.request.files:
             team.avatar = self.request.files['avatarfile'][0]['body']
         else:
             avatar = self.get_argument('avatar', team.avatar)
             if team.avatar != avatar and avatar != "":
                 #allow for default without setting
                 team._avatar = avatar
         self.dbsession.add(team)
         self.dbsession.commit()
         self.redirect('/admin/users')
     except ValidationError as error:
         self.render('admin/view/users.html',
                     errors=[str(error), ]
                     )
开发者ID:moloch--,项目名称:RootTheBox,代码行数:25,代码来源:AdminUserHandlers.py

示例9: get_team

# 需要导入模块: from models.Team import Team [as 别名]
# 或者: from models.Team.Team import by_uuid [as 别名]
 def get_team(self):
     ''' Create a team object, or pull the existing one '''
     team = Team.by_uuid(self.get_argument('team', ''))
     if team is not None and self.config.max_team_size <= len(team.members):
         raise ValidationError("Team %s is already full" % team.name)
     return team if team is not None else self.create_team()
开发者ID:WeiEast,项目名称:RootTheBox,代码行数:8,代码来源:PublicHandlers.py

示例10: edit_user

# 需要导入模块: from models.Team import Team [as 别名]
# 或者: from models.Team.Team import by_uuid [as 别名]
    def edit_user(self):
        ''' Update user objects in the database '''
        try:
            user = User.by_uuid(self.get_argument('uuid', ''))
            if user is None:
                raise ValidationError("User does not exist")
            handle = self.get_argument('handle', '')
            if user.handle != handle:
                if User.by_handle(handle) is None:
                    logging.info("Updated user handle %s -> %s" % (
                        user.handle, handle
                    ))
                    user.handle = handle
                else:
                    raise ValidationError("Handle is already in use")
            name = self.get_argument('name', '')
            email = self.get_argument('email', '')
            if user.name != name:
                logging.info("Updated user Name %s -> %s" % (
                        user.name, name
                    ))
                user.name = name
            if user.email != email:
                logging.info("Updated user Email %s -> %s" % (
                        user.email, email
                    ))
                user.email = email
            if options.banking:
                hash_algorithm = self.get_argument('hash_algorithm', '')
                if hash_algorithm != user.algorithm:
                    if hash_algorithm in user.algorithms:
                        if 0 < len(self.get_argument('bank_password', '')):
                            logging.info("Updated %s's hashing algorithm %s -> %s" % (
                                user.handle, user.algorithm, hash_algorithm,
                            ))
                            user.algorithm = hash_algorithm
                        else:
                            raise ValidationError(
                                "You must provide a new bank password when updating the hashing algorithm")
                    else:
                        raise ValidationError("Not a valid hash algorithm")
                if len(self.get_argument('bank_password', '')):
                    user.bank_password = self.get_argument('bank_password', '')
            password = self.get_argument('password', '')
            if password and len(password) > 0:
                user.password = password
            if hasattr(self.request, 'files') and 'avatarfile' in self.request.files:
                user.avatar = self.request.files['avatarfile'][0]['body']
            else:
                avatar = self.get_argument('avatar', user.avatar)
                #allow for default without setting
                user._avatar = avatar
            team = Team.by_uuid(self.get_argument('team_uuid', ''))
            if team is not None:
                if user not in team.members:
                    logging.info("Updated %s's team %s -> %s" % (
                        user.handle, user.team_id, team.name
                    ))
                    user.team_id = team.id
            elif options.teams:
                raise ValidationError("Team does not exist in database")
            self.dbsession.add(user)

            admin = self.get_argument('admin', 'false')
            if admin == 'true' and not user.is_admin():
                permission = Permission()
                permission.name = ADMIN_PERMISSION
                permission.user_id = user.id
                self.dbsession.add(permission)
            elif admin == 'false' and user.is_admin():
                permissions = Permission.by_user_id(user.id)
                for permission in permissions:
                    if permission.name == ADMIN_PERMISSION:
                        self.dbsession.delete(permission)
                
            self.dbsession.commit()
            self.redirect('/admin/users')
        except ValidationError as error:
            self.render("admin/view/users.html",
                        errors=[str(error), ]
                        )
开发者ID:moloch--,项目名称:RootTheBox,代码行数:83,代码来源:AdminUserHandlers.py


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