Example #1
0
 def create_team(self):
     """ Create a new team """
     if not self.config.teams:
         team = Team.by_name(self.get_argument("handle", ""))
         if team is None:
             team = Team()
             team.name = self.get_argument("handle", "")
         else:
             logging.info(
                 "Team %s already exists - Player Mode: reset team." % team.name
             )
             team.flags = []
             team.hints = []
             team.boxes = []
             team.items = []
             team.game_levels = []
             team.purchased_source_code = []
         team.motto = self.get_argument("motto", "")
         team._avatar = identicon(team.name, 6)
         if self.config.banking:
             team.money = self.config.starting_team_money
         else:
             team.money = 0
         levels = GameLevel.all()
         for level in levels:
             if level.type == "none":
                 team.game_levels.append(level)
             elif level.type != "hidden" and level.buyout == 0:
                 team.game_levels.append(level)
         return team
     elif self.config.public_teams:
         if Team.by_name(self.get_argument("team_name", "")) is not None:
             raise ValidationError(
                 "This team name is already registered.  Use team code to join that team."
             )
         team = Team()
         team.name = self.get_argument("team_name", "")
         team.motto = self.get_argument("motto", "")
         if len(filter_avatars("team")) == 0:
             team._avatar = identicon(team.name, 6)
         if not self.config.banking:
             team.money = 0
         level_0 = GameLevel.by_number(0)
         if not level_0:
             level_0 = GameLevel.all()[0]
         team.game_levels.append(level_0)
         return team
     else:
         raise ValidationError("Public teams are not enabled")
    def create_team(self):
        """ Admins can create teams manually """
        try:
            name = self.get_argument("team_name", "")
            if Team.by_name(name) is not None:
                raise ValidationError("Team already exists")
            team = Team()
            team.name = self.get_argument("team_name", "")
            team.motto = self.get_argument("motto", "")
            if not self.config.banking:
                team.money = 0
            level_0 = GameLevel.by_number(0)
            if not level_0:
                level_0 = GameLevel.all()[0]
            team.game_levels.append(level_0)
            self.dbsession.add(team)
            self.dbsession.commit()

            # Avatar
            avatar_select = self.get_argument("team_avatar_select", "")
            if avatar_select and len(avatar_select) > 0:
                team._avatar = avatar_select
            elif hasattr(self.request,
                         "files") and "avatar" in self.request.files:
                team.avatar = self.request.files["avatar"][0]["body"]
            self.dbsession.add(team)
            self.dbsession.commit()
            self.event_manager.push_score_update()
            self.redirect("/admin/users")
        except ValidationError as error:
            self.render("admin/create/team.html", errors=[str(error)])
Example #3
0
def create_team():
    team = Team()
    team.name = "TestTeam"
    team.motto = "TestMotto"
    dbsession.add(team)
    dbsession.commit()
    return team
    def create_team(self):
        ''' Admins can create teams manually '''
        try:
            name = self.get_argument('team_name', '')
            if Team.by_name(name) is not None:
                raise ValidationError("Team already exists")
            team = Team()
            team.name = self.get_argument('team_name', '')
            team.motto = self.get_argument('motto', '')
            if not self.config.banking:
                team.money = 0
            level_0 = GameLevel.by_number(0)
            if not level_0:
                level_0 = GameLevel.all()[0]
            team.game_levels.append(level_0)
            self.dbsession.add(team)
            self.dbsession.commit()

            # Avatar
            avatar_select = self.get_argument('team_avatar_select', '')
            if avatar_select and len(avatar_select) > 0:
                team._avatar = avatar_select
            elif hasattr(self.request, 'files') and 'avatar' in self.request.files:
                team.avatar = self.request.files['avatar'][0]['body']
            self.dbsession.add(team)
            self.dbsession.commit()
            self.redirect('/admin/users')
        except ValidationError as error:
            self.render("admin/create/team.html", errors=[str(error), ])
    def create_team(self):
        ''' Admins can create teams manually '''
        try:
            name = self.get_argument('team_name', '')
            if Team.by_name(name) is not None:
                raise ValidationError("Team already exists")
            team = Team()
            team.name = self.get_argument('team_name', '')
            team.motto = self.get_argument('motto', '')
            if not self.config.banking:
                team.money = 0
            level_0 = GameLevel.by_number(0)
            if not level_0:
                level_0 = GameLevel.all()[0]
            team.game_levels.append(level_0)
            self.dbsession.add(team)
            self.dbsession.commit()

            # Avatar
            avatar_select = self.get_argument('team_avatar_select', '')
            if avatar_select and len(avatar_select) > 0:
                team._avatar = avatar_select
            elif hasattr(self.request,
                         'files') and 'avatar' in self.request.files:
                team.avatar = self.request.files['avatar'][0]['body']
            self.dbsession.add(team)
            self.dbsession.commit()
            self.redirect('/admin/users')
        except ValidationError as error:
            self.render("admin/create/team.html", errors=[
                str(error),
            ])
Example #6
0
def create_team():
    team = Team()
    team.name = "TestTeam"
    team.motto = "TestMotto"
    dbsession.add(team)
    dbsession.commit()
    return team
Example #7
0
 def create_team(self):
     ''' Create a new team '''
     if not self.config.teams:
         team = Team.by_name(self.get_argument('handle', ''))
         if team is None:
             team = Team()
             team.name = self.get_argument('handle', '')
         else:
             logging.info(
                 "Team %s already exists - Player Mode: reset team." %
                 team.name)
             team.flags = []
             team.hints = []
             team.boxes = []
             team.items = []
             team.game_levels = []
             team.purchased_source_code = []
         team.motto = self.get_argument('motto', '')
         if self.config.banking:
             team.money = self.config.starting_team_money
         else:
             team.money = 0
         level_0 = GameLevel.by_number(0)
         if not level_0:
             level_0 = GameLevel.all()[0]
         team.game_levels.append(level_0)
         return team
     elif self.config.public_teams:
         if Team.by_name(self.get_argument('team_name', '')) is not None:
             raise ValidationError(
                 "This team name is already registered.  Use team code to join that team."
             )
         team = Team()
         team.name = self.get_argument('team_name', '')
         team.motto = self.get_argument('motto', '')
         if not self.config.banking:
             team.money = 0
         level_0 = GameLevel.by_number(0)
         if not level_0:
             level_0 = GameLevel.all()[0]
         team.game_levels.append(level_0)
         return team
     else:
         raise ValidationError("Public teams are not enabled")
Example #8
0
 def create_team(self):
     ''' Create a new team in the database '''
     team = Team()
     team.name = self.get_argument('team_name', '')
     team.motto = self.get_argument('motto', '')
     level_0 = GameLevel.all()[0]
     team.game_levels.append(level_0)
     self.dbsession.add(team)
     self.dbsession.commit()
     self.redirect('/admin/view/user_objects')
Example #9
0
 def create_team(self):
     ''' Create a new team '''
     if self.config.public_teams:
         team = Team()
         team.name = self.get_argument('team_name', '')
         team.motto = self.get_argument('motto', '')
         level_0 = GameLevel.all()[0]
         team.game_levels.append(level_0)
         return team
     else:
         raise ValidationError("Public teams are not enabled")
Example #10
0
 def create_team(self):
     ''' Create a new team '''
     if self.config.public_teams:
         team = Team()
         team.name = self.get_argument('team_name', '')
         team.motto = self.get_argument('motto', '')
         level_0 = GameLevel.all()[0]
         team.game_levels.append(level_0)
         return team
     else:
         raise ValidationError("Public teams are not enabled")
Example #11
0
 def create_team(self):
     ''' Create a new team '''
     if not self.config.teams:
         team = Team.by_name(self.get_argument('handle', ''))
         if team is None:
             team = Team()
             team.name = self.get_argument('handle', '')
         else:
             logging.info("Team %s already exists - Player Mode: reset team." % team.name)
             team.flags = []
             team.hints = []
             team.boxes = []
             team.items = []
             team.game_levels = []
             team.purchased_source_code = []
         team.motto = self.get_argument('motto', '')
         if self.config.banking:
             team.money = self.config.starting_team_money
         else:
             team.money = 0
         level_0 = GameLevel.by_number(0)
         if not level_0:
             level_0 = GameLevel.all()[0]
         team.game_levels.append(level_0)
         return team
     elif self.config.public_teams:
         if Team.by_name(self.get_argument('team_name', '')) is not None:
             raise ValidationError("This team name is already registered.  Use team code to join that team.")
         team = Team()
         team.name = self.get_argument('team_name', '')
         team.motto = self.get_argument('motto', '')
         if not self.config.banking:
             team.money = 0
         level_0 = GameLevel.by_number(0)
         if not level_0:
             level_0 = GameLevel.all()[0]
         team.game_levels.append(level_0)
         return team
     else:
         raise ValidationError("Public teams are not enabled")
Example #12
0
 def create_team(self, user):
     team = Team()
     team.name = user.handle
     team.motto = ""
     team._avatar = identicon(team.name, 6)
     if self.config.banking:
         team.money = self.config.starting_team_money
     else:
         team.money = 0
     level_0 = GameLevel.by_number(0)
     if not level_0:
         level_0 = GameLevel.all()[0]
     team.game_levels.append(level_0)
     self.dbsession.add(team)
     return team
 def create_team(self):
     ''' Admins can create teams manually '''
     try:
         name = self.get_argument('team_name', '')
         motto = self.get_argument('motto', '')
         if Team.by_name(name) is not None:
             raise ValidationError("Team already exists")
         team = Team()
         team.name = self.get_argument('team_name', '')
         team.motto = self.get_argument('motto', '')
         level_0 = GameLevel.all()[0]
         self.dbsession.add(team)
         self.dbsession.commit()
         self.redirect('/admin/users')
     except ValidationError as error:
         self.render("admin/create/team.html", errors=[str(error), ])
Example #14
0
 def create_team(self):
     ''' Admins can create teams manually '''
     try:
         name = self.get_argument('team_name', '')
         motto = self.get_argument('motto', '')
         if Team.by_name(name) is not None:
             raise ValidationError("Team already exists")
         team = Team()
         team.name = self.get_argument('team_name', '')
         team.motto = self.get_argument('motto', '')
         level_0 = GameLevel.all()[0]
         self.dbsession.add(team)
         self.dbsession.commit()
         self.redirect('/admin/users')
     except ValidationError as error:
         self.render("admin/create/team.html", errors=[
             str(error),
         ])
Example #15
0
def create_demo_user():
    from models.Team import Team
    from models.User import User
    from models.GameLevel import GameLevel
    from models import dbsession

    if Team.by_name("player") is None:
        user = User()
        user.handle = "player"
        user.password = "******"
        user.name = "player"
        user.email = "*****@*****.**"
        team = Team()
        team.name = "player"
        team.motto = "Don't hate the player"
        team.money = 0
        team.game_levels.append(GameLevel.all()[0])
        team.members.append(user)
        dbsession.add(user)
        dbsession.add(team)
        dbsession.commit()