Exemple #1
0
    def post(self):
        request_data = json.loads(self.request.body)
        logging.info(request_data)
        player = current_user_player()
        config = PlayerConfig.get_by_id(int(request_data['id']))

        # VALIDATION
        if not config.player == player.key:
            error_400(self.response, "ERROR_NOT_YOUR_PLAYER", "You activate another players config. You api-hacking or what?")
            return

        # UPDATE
        for active_config in PlayerConfig.query(PlayerConfig.player == player.key, PlayerConfig.active == True).fetch():
            active_config.active = False
            active_config.put()

        config.active = True
        config.put()

        set_json_response(self.response, {'code': "OK"})
Exemple #2
0
    def post(self):
        request_data = json.loads(self.request.body)
        logging.info(request_data)
        player = current_user_player()
        config = PlayerConfig.get_by_id(int(request_data['id']))

        # VALIDATION
        if not config.player == player.key:
            error_400(self.response, "ERROR_NOT_YOUR_PLAYER", "You cant delete another players config. You api-hacking or what?")
            return

        # DELETE
        config.key.delete()

        set_json_response(self.response, {'code': "OK"})
Exemple #3
0
    def post(self):
        request_data = json.loads(self.request.body)
        logging.info(request_data)
        player = current_user_player()
        config = PlayerConfig.get_by_id(int(request_data['id']))
        updated_hero_priorities = self._hero_priorities_cleaned_for_empty(request_data['hero_priorities'])

        # VALIDATION
        if not config.player == player.key:
            error_400(self.response, "ERROR_NOT_YOUR_PLAYER", "You cant update another players config. You api-hacking or what?")
            return
        if not self._validate_hero_priorities(updated_hero_priorities):
            return

        # UPDATE
        config.name = request_data['name']
        config.hero_priorities = updated_hero_priorities
        config.troll_level = request_data['troll_level']
        config.flame_level = request_data['flame_level']
        config.put()

        set_json_response(self.response, {'code': "OK"})
Exemple #4
0
 def post(self):
     player = current_user_player()
     first_config = PlayerConfig.query(PlayerConfig.player == player.key).count() == 0
     new_config = PlayerConfig(player=player.key, active=first_config).put().get()
     set_json_response(self.response, new_config.get_data())