Example #1
0
    def put(self, id):
        user = users.get_current_user()
        tourney = GetTourneyWithIdAndMaybeReturnStatus(self.response, id)
        if not tourney:
            return

        if not CheckUserOwnsTournamentAndMaybeReturnStatus(
                self.response, user, tourney):
            return

        request_dict = self._ParseRequestInfoAndMaybeSetStatus()
        if not request_dict:
            return

        name = request_dict['name']
        no_pairs = request_dict['no_pairs']
        no_boards = request_dict['no_boards']
        player_list = request_dict.get('players')
        if not self._CheckValidTournamentInfoAndMaybeSetStatus(
                name, no_pairs, no_boards, player_list):
            return
        if ((tourney.no_pairs != no_pairs or tourney.no_boards != no_boards)
                and len(tourney.GetScoredHandList()) != 0):
            SetErrorStatus(self.response, 400, "Invalid Request",
                           "Tournament already has registered hands")
            return
        self.response.set_status(204)
        tourney.no_pairs = no_pairs
        tourney.no_boards = no_boards
        tourney.name = name
        tourney_key = tourney.put()
        tourney.PutPlayers(player_list, no_pairs)
Example #2
0
  def put(self, id):
    user = users.get_current_user()
    tourney = GetTourneyWithIdAndMaybeReturnStatus(self.response, id)
    if not tourney:
      return

    if not CheckUserOwnsTournamentAndMaybeReturnStatus(self.response, user,
                                                       tourney):
      return

    request_dict = self._ParseRequestInfoAndMaybeSetStatus()
    if not request_dict:
      return

    name = request_dict['name']
    no_pairs = request_dict['no_pairs']
    no_boards = request_dict['no_boards']
    player_list = request_dict.get('players')
    allow_score_overwrites = request_dict.get('allow_score_overwrites', False)
    if not self._CheckValidTournamentInfoAndMaybeSetStatus(name, no_pairs,
                                                           no_boards,
                                                           player_list,
                                                           tourney.legacy_version_id):
      return
    if ((tourney.no_pairs != no_pairs or tourney.no_boards != no_boards) and
         len(tourney.GetScoredHandList()) != 0):
      SetErrorStatus(self.response, 400, "Invalid Request",
                     "Tournament already has registered hands")
      return
   
    old_no_pairs = tourney.no_pairs   
    tourney.no_pairs = no_pairs
    tourney.no_boards = no_boards
    tourney.name = name
    if allow_score_overwrites:
      tourney.Unlock()
    else:
      tourney.MakeLockable()
    tourney.PutPlayers(player_list, old_no_pairs)
    tourney_key = tourney.put_async()
    self.response.set_status(204)