Example #1
0
def items(query=None, user=LOGGED_IN_USER, username=USER):
    """
    Given an LQL query and a library identity, return the items that match.
    """
    library = Library.objects.get()
    items = Item.objects.all()
    query_json = '[]'

    if query:
        from query import execute_query, parse_query
        parsed = parse_query(query)
        items = execute_query(items, parsed)
        # this json representation of the query that was just used to filter
        # the items will be passed back to the template as a json string
        # so the front end can render the query widget. A string representation
        # is not passed because there is no way to parse LQL in javascript (yet).
        query_json = jsonify(parsed)

    items = items.all()
    all_keys = []
    return {
        'parsed_query_json': query_json,
        'library_items': items,
        'items_count': len(items),
        'keys': all_keys,
    }
Example #2
0
 def generic_json(self, result, errors):
     return {'body': jsonify(result), 'mimetype': 'application/json'}
Example #3
0
 def renderer(self, data, errors):
     return jsonify(data)
Example #4
0
 def generic_json(self, result, errors):
     return {'body': jsonify(result), 'mimetype': 'application/json'}