Exemplo n.º 1
0
    def post(self):
        request_data = json.loads(self.request.body)
        logging.info(request_data)
        player = current_user_player()
        team_key = player.team
        tournament = Tournament.get_by_id(int(request_data['tournament_id']))

        if team_key in tournament.participants:
            error_400(self.response, "ERROR_ALREADY_IN_TOURNAMENT", "Your team has already joined the tournament '%s'" % tournament.name)
            return

        tournament.participants.append(team_key)
        tournament.put()

        set_json_response(self.response, {'code': "OK"})
Exemplo n.º 2
0
def GetTourneyWithIdAndMaybeReturnStatus(response, id):
    ''' Fetches a tournament with requested id.
   
  Args:
    response: Response.
    id: String. Unique id assigned to the desired tournament.

  Side effects:
    Sets response to status 403 with a detailed error if tournament does not
      exist.

  Returns:
    Tournament corresponding to the id or None if it does not exist.
  '''
    if not is_int(id):
        TourneyDoesNotExistStatus(response, id)
        return None
    tourney = Tournament.get_by_id(int(id))
    if not tourney:
        TourneyDoesNotExistStatus(response, id)
        return None
    return tourney
Exemplo n.º 3
0
def setLegacyId(self, id='123', version=1):
    tourney = Tournament.get_by_id(int(id))
    tourney.legacy_version_id = version
    tourney.put()