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


Python Team.by_uuid方法代码示例

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


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

示例1: edit_users

# 需要导入模块: from models import Team [as 别名]
# 或者: from models.Team import by_uuid [as 别名]
 def edit_users(self):
     ''' Update user objects in the database '''
     form = Form(
         uuid="User not selected",
         account="Please enter an account name",
         handle="Please enter a handle name",
         hash_algorithm="Please select a hash algorithm",
         team_uuid="Please select a team",
     )
     if form.validate(self.request.arguments):
         errors = []
         user = User.by_uuid(self.get_argument('uuid'))
         if user is not None:
             # Update user account name
             if user.account != self.get_argument('account'):
                 if User.by_account(self.get_argument('account')) is None:
                     logging.info("Updated user account %s -> %s" %
                         (user.account, self.get_argument('account'),))
                     user.account = unicode(self.get_argument('account'))
                 else:
                     errors.append("Account name is already in use")
             # Update user handle
             if user.handle != self.get_argument('handle'):
                 if User.by_handle(self.get_argument('handle')) is None:
                     logging.info("Updated user handle %s -> %s" %
                         (user.handle, self.get_argument('handle'),))
                     user.handle = unicode(self.get_argument('handle'))
                 else:
                     errors.append("Handle is already in use")
             # Update hashing algoritm
             if self.get_argument('hash_algorithm') in user.algorithms:
                 if user.algorithm != self.get_argument('hash_algorithm'):
                     if 0 < len(self.get_argument('password', '')):
                         logging.info("Updated %s's hashing algorithm %s -> %s" %
                             (user.handle, user.algorithm, self.get_argument('hash_algorithm'),)
                         )
                         user.algorithm = self.get_argument('hash_algorithm')
                     else:
                         errors.append("You must provide a password when updating the hashing algorithm")
             else:
                 errors.append("Not a valid hash algorithm")
             # Update password
             if 0 < len(self.get_argument('password', '')):
                 user.password = self.get_argument('password')
             # Update team
             team = Team.by_uuid(self.get_argument('team_uuid'))
             if team is not None:
                 if user.team_id != team.id:
                     logging.info("Updated %s's team %s -> %s" %
                         (user.handle, user.team_id, team.name))
                     user.team_id = team.id
             else:
                 errors.append("Team does not exist in database")
             dbsession.add(user)
             dbsession.flush()
         else:
             errors.append("User does not exist")
         self.render("admin/view/user_objects.html", errors=errors)
     else:
         self.render("admin/view/user_objects.html", errors=form.errors)
开发者ID:mach327,项目名称:RootTheBox,代码行数:62,代码来源:AdminHandlers.py

示例2: post

# 需要导入模块: from models import Team [as 别名]
# 或者: from models.Team import by_uuid [as 别名]
 def post(self, *args, **kwargs):
     ''' Attempts to create an account, with shitty form validation '''
     form = Form(
         account="Please enter an account name",
         handle="Please enter a handle",
         team="Please select a team to join",
         pass1="Please enter a password",
         pass2="Please confirm your password",
         token="Please enter a registration token"
     )
     if form.validate(self.request.arguments):
         config = ConfigManager.Instance()
         account = self.get_argument('account').lower()
         handle = self.get_argument('handle').lower()
         rtok = self.get_argument('token', '__none__').lower()
         passwd = self.get_argument('pass1')
         if User.by_account(account) is not None:
             self.render('public/registration.html',
                 errors=['Account name already taken']
             )
         elif account == handle:
             self.render('public/registration.html',
                 errors=['Account name and hacker name must differ']
             )
         elif User.by_handle(handle) is not None:
             self.render('public/registration.html',
                 errors=['Handle already taken']
             )
         elif not passwd == self.get_argument('pass2'):
             self.render('public/registration.html',
                 errors=['Passwords do not match']
             )
         elif not 0 < len(passwd) <= config.max_password_length:
             self.render('public/registration.html',
                 errors=['Password must be 1-%d characters'
                             % config.max_password_length]
             )
         elif Team.by_uuid(self.get_argument('team', '')) is None:
             self.render('public/registration.html',
                 errors=["Please select a team to join"]
             )
         elif RegistrationToken.by_value(rtok) is None and not config.debug:
             self.render('public/registration.html',
                 errors=["Invalid registration token"]
             )
         else:
             self.create_user(account, handle, passwd, rtok)
             self.render('public/successful_reg.html', account=account)
     else:
         self.render('public/registration.html', errors=form.errors)
开发者ID:brutalhonesty,项目名称:RootTheBox,代码行数:52,代码来源:PublicHandlers.py

示例3: create_user

# 需要导入模块: from models import Team [as 别名]
# 或者: from models.Team import by_uuid [as 别名]
 def create_user(self, account, handle, passwd, rtok):
     ''' Add user to the database '''
     team = Team.by_uuid(self.get_argument('team', ''))
     user = User(
         account=unicode(account),
         handle=unicode(handle),
         team_id=team.id,
     )
     dbsession.add(user)
     dbsession.flush()
     user.password = passwd
     token = RegistrationToken.by_value(rtok)
     if token is not None:  # May be None if debug mode is on
         token.used = True
         dbsession.add(token)
     dbsession.add(user)
     dbsession.flush()
     self.event_manager.joined_team(user)
开发者ID:brutalhonesty,项目名称:RootTheBox,代码行数:20,代码来源:PublicHandlers.py

示例4: edit_teams

# 需要导入模块: from models import Team [as 别名]
# 或者: from models.Team import by_uuid [as 别名]
 def edit_teams(self):
     ''' Edit existing team objects in the database '''
     form = Form(
         uuid="No team selected",
         name="Please enter a name",
         motto="Please enter a motto",
         listen_port="Please enter a listen port",
     )
     if form.validate(self.request.arguments):
         team = Team.by_uuid(self.get_argument('uuid'))
         if team is not None:
             errors = []
             if team.name != self.get_argument('name'):
                 logging.info("Updated team name %s -> %s" %
                     (team.name, self.get_argument('name'),)
                 )
                 team.name = unicode(self.get_argument('name'))
             if team.motto != self.get_argument('motto'):
                 logging.info("Updated %s's motto %s -> %s" %
                     (team.name, team.motto, self.get_argument('motto'),)
                 )
                 team.motto = unicode(self.get_argument('motto'))
             try:
                 lport = int(self.get_argument('listen_port'))
                 if lport != team.listen_port:
                     logging.info("Updated %s's listen port %d -> %d" %
                         (team.name, team.listen_port, lport,)
                     )
                     team.listen_port = lport
             except ValueError:
                 errors.append("Invalid listen port %s " %
                     self.get_argument('listen_port')
                 )
             dbsession.add(team)
             dbsession.flush()
             self.redirect("/admin/view/user_objects")
         else:
             self.render("admin/view/user_objects.html",
                 errors=["Team does not exist"]
             )
     else:
         self.render("admin/view/user_objects.html", errors=form.errors)
开发者ID:mach327,项目名称:RootTheBox,代码行数:44,代码来源:AdminHandlers.py

示例5: team_details

# 需要导入模块: from models import Team [as 别名]
# 或者: from models.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:lavalamp-,项目名称:RootTheBox,代码行数:23,代码来源:ScoreboardHandlers.py

示例6: validate_team

# 需要导入模块: from models import Team [as 别名]
# 或者: from models.Team import by_uuid [as 别名]
 def validate_team(self):
     ''' Validate team arguments '''
     errors = []
     team = Team.by_uuid(self.get_argument('team', ''))
     if team is None:
         if self.config.public_teams:
             team_name = self.get_argument('team_name', '')
             motto = self.get_argument('motto', '')
             if 2 < len(team_name) < 15:
                 if Team.by_name(team_name) is not None:
                     errors.append("A team with that name already exists")
             else:
                 errors.append('Team name must be 3 - 15 characters')
             if not 2 < len(motto) < 255:
                 errors.append('Team motto must be more than 3 characters')  
         else:
             errors.append("You must select a team to join")
     else:
         if not len(team.members) < self.config.max_team_size:
             errors.append("This team is full, please select another to join.")
     return errors
开发者ID:CRYPTOlab,项目名称:RootTheBox,代码行数:23,代码来源:PublicHandlers.py

示例7: get_team

# 需要导入模块: from models import Team [as 别名]
# 或者: from models.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', ''))
     return team if team is not None else self.create_team()
开发者ID:CRYPTOlab,项目名称:RootTheBox,代码行数:6,代码来源:PublicHandlers.py


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