def handle_post(self, player):
     """ Receives the updated round scores from a player after they complete a round. """
     game = ndb.Key(urlsafe=self.request.get("game_key")).get()
     new_score = int(self.request.get("new_score"))
     if player.key == game.creator_key:
         game.creator_scores.append(new_score)
     else:
         if len(game.invitee_scores) == 0:
             player_utils.update_past_opponents(game)
         game.invitee_scores.append(new_score)
     game.is_complete = game_utils.is_game_complete(game)
     game.put()
     self.redirect(self.request.referer)
 def game_addscore(self, game):
   """ Add a score to a game """
   if game.entityKey is None or game.new_score is None:
     raise endpoints.BadRequestException("Missing required properties")
   # Figure out whose score the new one is.
   player = player_utils.get_player_from_email(endpoints.get_current_user().email())
   if player.key == game.creator_key:
     game.creator_scores.append(game.new_score)
   else:
     # If this is the first invitee round, update past_opponent on each player.
     if len(game.invitee_scores) == 0:
       player_utils.update_past_opponents(game) 
     game.invitee_scores.append(game.new_score)
   game.new_score = None
   game.is_complete = game_utils.is_game_complete(game)
   game.put()
   return game