Esempio n. 1
0
def index():
    authz.require(authz.system_read())
    q = Context.all()
    if arg_bool('imports'):
        q = q.filter(Context.resource_name != None) # noqa
    q = q.order_by(Context.updated_at.desc())
    return jsonify(Pager(q))
Esempio n. 2
0
def index():
    authz.require(authz.system_read())
    q = {}
    prefix = request.args.get("prefix", "")
    if len(prefix):
        q = {"label~=": prefix}
    q = EntityQuery(q)
    return jsonify(Pager(q))
Esempio n. 3
0
def spiders():
    authz.require(authz.system_read())
    spiders = {}
    for name, spider in get_spiders().items():
        spiders[name] = {
            "name": name,
            "class": spider.__name__,
            "label": spider.PUBLISHER_LABEL,
            "url": spider.PUBLISHER_URL,
        }
    return jsonify(spiders)
Esempio n. 4
0
def query():
    authz.require(authz.system_read())
    if request.method == "GET":
        try:
            q = json.loads(request.args.get("q"))
        except (TypeError, ValueError) as e:
            data = {"status": "error", "message": "Invalid query: %s" % unicode(e)}
            return jsonify(data, status=400)
    else:
        q = request_data()
    return jsonify(execute_query(q))
Esempio n. 5
0
def status():
    return jsonify({
        'logged_in': authz.logged_in(),
        'api_key': current_user.api_key if authz.logged_in() else None,
        'user': current_user if authz.logged_in() else None,
        'permissions': {
            READ: authz.system_read(),
            EDIT: authz.system_edit(),
            MANAGE: authz.system_manage()
        },
        'logout': url_for('.logout')
    })
Esempio n. 6
0
def view(id):
    authz.require(authz.system_read())
    context = obj_or_404(Context.by_id(id))
    return jsonify(context)
Esempio n. 7
0
def view(id):
    authz.require(authz.system_read())
    user = obj_or_404(User.by_id(id))
    data = user.to_dict()
    return jsonify(data)
Esempio n. 8
0
def view(id):
    authz.require(authz.system_read())
    entity = obj_or_404(EntityQuery.by_id(id))
    return jsonify(entity)