Ejemplo n.º 1
0
def generic_acl(klass, uri, acllist):
    owner = g.user_id
    fldr = model.get_by_id(klass, uri, owner)
    fldr.set_acls(owner, acllist)
    resp = flask.make_response(fldr.jsonify())
    resp.status_code = 200
    resp.content_type = 'application/json'
    return resp
Ejemplo n.º 2
0
def generic_acl(klass, uri, acllist):
    owner = g.userID
    fldr = model.get_by_id(klass, uri, owner)
    fldr.set_acls(owner, acllist)
    resp = flask.make_response(json.dumps(fldr.__complex__(owner)))
    resp.status_code = 200
    resp.content_type = 'application/json; charset=utf-8'
    return resp
Ejemplo n.º 3
0
def acl_module_put(uri):
    """ """
    requesting_user_uri = g.user_id
    if request.method == "PUT":
        jsond = request.json
        return generic_acl(model.Module, uri, jsond)
    elif request.method == "GET":
        obj = model.get_by_id(model.Module,
                                    uri, requesting_user_uri)
        return str(obj.userroles)
Ejemplo n.º 4
0
def collection_acl_put(collectionuri):
    """ """
    requesting_user_uri = g.user_id
    if request.method == "PUT":
        jsond = request.json
        return generic_acl(model.Collection, collectionuri, jsond)
    elif request.method == "GET":
        obj = model.get_by_id(model.Collection,
                                    collectionuri, requesting_user_uri)
        return str(obj.userroles)
Ejemplo n.º 5
0
def folder_get(folderuri):
    """    """
    foldbody=[]
    fold = model.get_by_id(model.Folder, folderuri, g.user_id)
    foldjson = fold.to_dict()
    for obj in fold.body:
        try:
           mod  = model.get_by_id(model.Module, obj, g.user_id)
           foldbody.append({"id":mod.id_,"title":mod.title,"mediaType":mod.mediaType})
        except:  # FIXME want to catch no such object error
           pass
    foldjson['body'] = foldbody
    foldjson['id'] = foldjson.pop('id_')
    
    resp = flask.make_response(json.dumps(foldjson))
    resp.content_type = 'application/json'
    resp.headers["Access-Control-Allow-Origin"] = "*"

    auth.callstatsd('rhaptos2.e2repo.workspace.GET')
    return resp
Ejemplo n.º 6
0
def generic_get(klass, uri, requesting_user_uri):
    mod = model.get_by_id(klass, uri, requesting_user_uri)
    resp = flask.make_response(mod.jsonify())
    resp.status_code = 200
    resp.content_type = 'application/json'
    return resp