Beispiel #1
0
    def get(self):
        query = request.args.get('query','')
        type = request.args.get('type')
        limit = request.args.get('limit')
        forms = request.args.get('forms', 'false') == 'true'
        ability = request.args.get('ability',None)
        abilities = request.args.get('abilities', 'false') == 'true'
        add_pokemon_search_history(request.remote_addr, query)
        #abilities_matching = search_abilities(query, ability=ability, limit=limit)
        pokemons_matching = search_pokemons(query, type=type, ability=ability, limit=limit)
        pokemons = [pokemon.get_small_data() for pokemon in pokemons_matching]

        if forms:
            for pokemon in pokemons:
                pokemon['forms'] = []

                forms_of_this_pokemon = get_forms_of_pokemons(pokemon['id'])
                for forms in forms_of_this_pokemon:
                    pokemon['forms'].append(forms.name)
        if abilities:
            for pokemon in pokemons:
                pokemon['abilities'] = []

                abilities_of_this_pokemon = get_abilities_of_pokemons(pokemon['id'])
                for pokemon_abilities in abilities_of_this_pokemon:
                    pokemon['abilities'].append(pokemon_abilities.ability.name)
        return pokemons
Beispiel #2
0
    def get(self):
        query = request.args['query']
        type = request.args.get('type')
        ability = request.args.get('ability')
        limit = request.args.get('limit')

        pokemons_matching = search_pokemons(query, type, ability, limit)
        pokemons = [pokemon.get_small_data() for pokemon in pokemons_matching]

        add_pokemon_search_history(request.remote_addr, query)

        return pokemons
Beispiel #3
0
    def get(self):
        # query = request.args['query']
        query = request.args.get('query', "")
        type_query = request.args.get('type', None)
        ability_query = request.args.get('filter_ability', None)
        ask_effect = request.args.get('effect', 'false') == 'true'
        ask_shape = request.args.get('shape', 'false') == 'true'
        show_abilities = request.args.get('show_abilities', 'false') == 'true'
        pokemons_matching = search_pokemons(query, ability_query, type_query)
        pokemons = [pokemon.get_small_data(ask_effect, ask_shape, show_abilities) for pokemon in pokemons_matching]

        add_pokemon_search_history(request.remote_addr, query)

        return pokemons
Beispiel #4
0
    def get(self):
        query = request.args.get('query')
        typo = request.args["type"]
        limit = int(request.args["limit"])
        print(typo)
        print(query)
        forms = bool(request.args["forms"])
        pokemons_matching = search_pokemons(query, typo, limit)
        pokemons = [pokemon.get_small_data() for pokemon in pokemons_matching]
        if forms == True:
            pokemons = [{
                "pokemons": pokemon.get_small_data(),
                "forms": get_pokemon_form(pokemon)
            } for pokemon in pokemons_matching]
        useragent = request.user_agent
        add_pokemon_search_history(request.remote_addr, query, useragent)

        return pokemons
Beispiel #5
0
 def get(self):
     query = request.args['query']
     pokemons_matching = search_pokemons(query, type=None)
     pokemons = [pokemon.get_small_data() for pokemon in pokemons_matching]
     return pokemons