Exemplo n.º 1
0
 def get(self, hunt_id):
     hunt = get_hunt_by_id(hunt_id)
     if not hunt:
         self.redirect('/')
         return
     teams = list(Team.all().filter('hunt = ', hunt))
     self.response.out.write(utils.render('templates/teams.html', {
         'hunt': hunt,
         'hunt_name': hunt.name,
         'started': bool(hunt.started),
         'teams': teams,
         'teams_json': json.dumps([{
             'id': team.key().id(),
             'name': team.name,
             'phone': team.phone,
             } for team in teams]),
         }))
Exemplo n.º 2
0
 def get(self, hunt_id):
     hunt = get_hunt_by_id(hunt_id)
     if not hunt:
         self.redirect("/")
         return
     teams = list(Team.all().filter("hunt = ", hunt))
     self.response.out.write(
         utils.render(
             "templates/teams.html",
             {
                 "hunt": hunt,
                 "hunt_name": hunt.name,
                 "started": bool(hunt.started),
                 "teams": teams,
                 "teams_json": json.dumps(
                     [{"id": team.key().id(), "name": team.name, "phone": team.phone} for team in teams]
                 ),
             },
         )
     )
Exemplo n.º 3
0
    def post(self, hunt_id):
        hunt = get_hunt_by_id(hunt_id)
        if not hunt:
            self.redirect('/')
            return
        teams_list = parse_json_objs(self.request.get('teams-list'), ['name', 'phone'])
        if not teams_list:
            self.redirect('/')
            return
        if not all(PHONE_NUMBER_RE.match(team['phone']) for team in teams_list):
            self.redirect('/')
            return
        if hunt.started:
            # TODO update existing teams
            pass
        else:
            for team in Team.all().filter('hunt =', hunt):
                team.delete()

            for team_dict in teams_list:
                Team(hunt=hunt, name=team_dict['name'], phone=team_dict['phone']).put()
        self.redirect('/hunt/%s/teams' % hunt.key().id())
Exemplo n.º 4
0
    def post(self, hunt_id):
        hunt = get_hunt_by_id(hunt_id)
        if not hunt:
            self.redirect("/")
            return
        teams_list = parse_json_objs(self.request.get("teams-list"), ["name", "phone"])
        if not teams_list:
            self.redirect("/")
            return
        if not all(PHONE_NUMBER_RE.match(team["phone"]) for team in teams_list):
            self.redirect("/")
            return
        if hunt.started:
            # TODO update existing teams
            pass
        else:
            for team in Team.all().filter("hunt =", hunt):
                team.delete()

            for team_dict in teams_list:
                hunt.add_team(team_dict["name"], team_dict["phone"])
        self.redirect("/hunt/%s/teams" % hunt.key().id())