def rooms(page=0): """ Returns all rooms that match the given querystring """ pg_query, values = query.build_query(TABLE, room_attributes, page=page) g.cursor.execute(pg_query, values) results = g.cursor.fetchall() if not len(results): # no results raise errors.AppError('NO_RESULTS') return make_response(json.dumps({ 'results': results, 'status': 200 }), 200)
def options(attr): """ Returns all options found in the database for this attribute @param attr: an attribute of the room objects """ if attr not in room_attributes: raise errors.AppError('INVALID_ATTRIBUTE') # strip the dictionary down to the releveant attribute relevant_values = {attr: room_attributes[attr]} pg_query, values = query.build_query(TABLE, relevant_values) g.cursor.execute(pg_query, values) results = g.cursor.fetchall() if not len(results): # no results, shouldn't be called raise errors.AppError('NO_RESULTS') return make_response(json.dumps({ 'results': results, 'status': 200 }), 200)