def search(request): """Search the database for annotations matching with the given query.""" return logic.search_annotations( request.params, get_user(request), request.feature('search_normalized') )
def annotations_index(request): """Do a search for all annotations on anything and return results. This will use the default limit, 20 at time of writing, and results are ordered most recent first. """ user = get_user(request) return h.api.search.index(user=user)
def search(request): """Search the database for annotations matching with the given query.""" search_normalized_uris = request.feature('search_normalized') # The search results are filtered for the authenticated user user = get_user(request) results = search_lib.search(request_params=request.params, user=user, search_normalized_uris=search_normalized_uris) return { 'total': results['total'], 'rows': [search_lib.render(a) for a in results['rows']], }
def annotations_index(request): """Do a search for all annotations on anything and return results. This will use the default limit, 20 at time of writing, and results are ordered most recent first. """ search_normalized_uris = request.feature('search_normalized') user = get_user(request) results = search_lib.index(user=user, search_normalized_uris=search_normalized_uris) return { 'total': results['total'], 'rows': [search_lib.render(a) for a in results['rows']], }
def create(request): """Read the POSTed JSON-encoded annotation and persist it.""" # Read the annotation from the request payload try: fields = request.json_body except ValueError: return _api_error(request, 'No JSON payload sent. Annotation not created.', status_code=400) # Client Error: Bad Request user = get_user(request) # Create the annotation annotation = logic.create_annotation(fields, user) # Notify any subscribers _publish_annotation_event(request, annotation, 'create') # Return it so the client gets to know its ID and such return search_lib.render(annotation)
def search(request): """Search the database for annotations matching with the given query.""" # The search results are filtered for the authenticated user user = get_user(request) return h.api.search.search(request.params, user)