def get(self): pokemons = request.args.get('pokemons', 'false') == 'true' query = request.args.get('query', None) types = get_types(query) result = [] for type in types: type_result = type.get_small_data() if pokemons: type_result['pokemons'] = [] pokemons_of_this_type = get_pokemons_from_type(type.id) for pokemon in pokemons_of_this_type: pokemon_result = {'id': pokemon.id, 'name': pokemon.name} type_result['pokemons'].append(pokemon_result) result.append(type_result) return result
def get(self): pokemons = request.args.get('pokemons', 'false') == 'true' types = get_types() if types is None: raise TypeNotFoundError result = [] for type in types: type_result = type.get_small_data() if pokemons: type_result['pokemons'] = [] pokemons_of_this_type = get_pokemons_from_type(type.id) for pokemon in pokemons_of_this_type: pokemon_result = {'id': pokemon.id, 'name': pokemon.name} type_result['pokemons'].append(pokemon_result) result.append(type_result) return result
def get(self): pokemons = request.args.get('pokemons', 'false') == 'true' unused = request.args.get('unused', 'false') == 'true' query = request.args.get('query', None) types = get_types(search=query, unused=unused) result = [] for type in types: type_result = type.get_small_data() if pokemons: type_result['pokemons'] = [] pokemons_of_this_type = get_pokemons_from_type(type.id) for pokemon in pokemons_of_this_type: pokemon_result = pokemon.get_small_data() type_result['pokemons'].append(pokemon_result) result.append(type_result) return result