Exemple #1
0
def autocomplete_locations():
    """
    Query string arguments:

        term (str)
    """
    term = request.args.get('term', '').strip()
    suggestions = []
    if term:
        suggestions = geocoding.get_coordinates(
            term, limit=autocomplete.MAX_LOCATIONS)
    if not suggestions:
        suggestions = search_util.build_location_suggestions(term)
        if suggestions:
            pass  # FIXME log BAN LIKELY DOWN event
    for suggestion in suggestions:
        suggestion['value'] = suggestion['label']
    return make_response(json.dumps(suggestions))
Exemple #2
0
 def test_suggest_locations_paris_1_findable(self):
     term = "paris 1"
     suggestions = search.build_location_suggestions(term)
     city_names = [suggestion['city'] for suggestion in suggestions]
     self.assertTrue("paris - 1er" in city_names)
Exemple #3
0
 def test_suggest_locations_pezziardi_lilas_first(self):
     term = "lilas"
     suggestions = search.build_location_suggestions(term)
     city_names = [suggestion['city'] for suggestion in suggestions]
     self.assertEquals("lilas", city_names[0])
Exemple #4
0
 def test_suggest_locations_pau_first(self):
     term = "pau"
     suggestions = search.build_location_suggestions(term)
     city_names = [suggestion['city'] for suggestion in suggestions]
     self.assertEquals("pau", city_names[0])
Exemple #5
0
def suggest_locations():
    term = request.args.get('term', '')
    suggestions = search_util.build_location_suggestions(term)
    return make_response(json.dumps(suggestions))