Beispiel #1
0
def get_places_from_db(lat=None, lon=None, x_1=None, x_2=None, y_1=None, y_2=None,
                filter_by_wifi=MUST_HAVE_WIFI, filter_by_plugs=MUST_HAVE_PLUGS):
    if not (lat and lon) and not (x_1 and x_2 and y_1 and y_2):
        return ErrorResponse.GET_INVALID_ARGS
    
    if (lat and lon):
        places = Place.get_places(lat=lat, lon=lon)
    if (x_1 and x_2 and y_1 and y_2):
        box = [[x_1, y_1], [x_2, y_2]]
        places = Place.get_places(box=box)
    
    places_output = process_places_from_db(places, filter_by_wifi=filter_by_wifi, filter_by_plugs=filter_by_plugs)
    return places_output