Example #1
0
 def validate_teamcode(self, teamcode):
     if len(teamcode) == 0:
         raise ValidationError("Invalid team code")
     team = Team.by_code(teamcode)
     if not team:
         raise ValidationError("Invalid team code")
     elif self.config.max_team_size <= len(team.members):
         raise ValidationError("Team %s is already full" % team.name)
     return teamcode
Example #2
0
 def get_team(self):
     ''' Create a team object, or pull the existing one '''
     code = self.get_argument('team-code', '')
     if len(code) > 0:
         team = Team.by_code(code)
         if not team:
             raise ValidationError("Invalid team code")
         elif self.config.max_team_size <= len(team.members):
             raise ValidationError("Team %s is already full" % team.name)
         return team
     return self.create_team()
Example #3
0
 def get_team(self):
     """ Create a team object, or pull the existing one """
     code = self.get_argument("team-code", "")
     if len(code) > 0:
         team = Team.by_code(code)
         if not team:
             raise ValidationError("Invalid team code")
         elif self.config.max_team_size <= len(team.members):
             raise ValidationError("Team %s is already full" % team.name)
         return team
     return self.create_team()
Example #4
0
 def needs_team(self, hasAdminRole, user, team_code):
     needsateam = False
     # Is the a member of a team, if not admin?
     if not hasAdminRole:
         if user is not None:
             if user.team is None:
                 # Have they entered a joining code from the join team page?
                 if team_code is not None and len(team_code) > 0:
                     team = Team.by_code(team_code)
                     user.team = team
                 else:
                     needsateam = True
         # New user must have teamcode for joining a team.
         elif team_code is None or len(team_code) == 0:
             needsateam = True
     return needsateam
Example #5
0
 def add_user(self, claims, team_code):
     user = User()
     user.uuid = claims["oid"]
     user.handle = claims["preferred_username"].split("@")[0]
     # Generate a long random password that the user will never know or use.
     user.password = "".join(
         secrets.choice(string.ascii_letters + string.digits +
                        string.punctuation) for i in range(30))
     user.bank_password = ""
     user.name = claims["name"]
     user.email = claims["email"]
     user.theme = options.default_theme
     user.last_login = datetime.now()
     user.logins = 1
     if not self.is_admin(claims):
         user.team = Team.by_code(team_code)
     self.dbsession.add(user)
     return user