def get(self): """ Currently not implemented. """ ALLOWED_FILTERS = frozenset([ 'city_id', 'gender', 'age', 'n_refs', 'n_friends', 'has_details', 'can_host', 'keywords']) search_dict = parse_search_fields() if search_dict.get('fields'): # only some filters are allowed search_dict['fields'] = dict( (k, v) for k, v in search_dict['fields'].iteritems() if k in ALLOWED_FILTERS) resp = query(User, **search_dict) return jsonify([obj.serialized for _, obj in resp] if resp else [])
def get(self, loctype): logged_user = get_logged_user() if loctype not in LOCATION_TYPE_MAPPING: return ('TYPE', '400', []) location_class = LOCATION_TYPE_MAPPING[loctype] #loc_query = location_class.query #if logged_user: # make_point = lambda c: func.ST_SetSRID( # func.ST_Point(c.x, c.y), 4326) # loc_query = loc_query.filter( # func.ST_Distance_Sphere( # make_point(location_class.coordinates), # make_point(logged_user.city.coordinates)) < 100000) fields = parse_search_fields() fields['query_field'] = 'name' resp = search.query(location_class, **fields) return jsonify([obj.serialized for _, obj in resp])