Ejemplo n.º 1
0
def log_history(payload, req):
    uid =  UR.getUserInfo(req, True).id
    if uid is None: 
        #SACHA TODO: LOG this.
        return UR.prepare_response({}, 1,  "NOT ALLOWED")
    cid = UR.CID
    if cid == 0:        
        return  UR.prepare_response({}, 1, "CID MOST BE NONZERO")
    session, previous_activity = annotations.markActivity(cid)
    if session is None: 
        return  UR.prepare_response({}, 1, "SESSION NOT FOUND")
    id_session = session.id
    output={}
    if "seen" in payload and cid != 0: 
        annotations.markCommentSeen(uid, id_session, payload["seen"])
    if "page" in payload and cid != 0: 
        annotations.markPageSeen(uid, id_session,  payload["page"])
    if "idle" in payload and cid != 0: 
        annotations.markIdle(uid,  id_session, payload["idle"])        
    if "__return" in payload and cid != 0:
        R = payload["__return"]
        if R["type"] == "newNotesOnFile": 
            id_source = R["a"]["id_source"]
            if auth.canReadFile(uid, id_source):
                output["locations"], output["comments"] = annotations.getCommentsByFile(id_source, uid, previous_activity)             
    return UR.prepare_response(output)
Ejemplo n.º 2
0
def log_history(payload, req):
    uid =  UR.getUserInfo(req, True).id
    if uid is None: 
        #SACHA TODO: LOG this.
        return UR.prepare_response({}, 1,  "NOT ALLOWED")
    cid = UR.CID
    if cid == 0:        
        return  UR.prepare_response({}, 1, "CID MOST BE NONZERO")
    session, previous_activity = annotations.markActivity(cid)
    if session is None: 
        return  UR.prepare_response({}, 1, "SESSION NOT FOUND")
    id_session = session.id
    output={}
    if "seen" in payload and cid != 0: 
        annotations.markCommentSeen(uid, id_session, payload["seen"])
    if "page" in payload and cid != 0: 
        annotations.markPageSeen(uid, id_session,  payload["page"])
    if "idle" in payload and cid != 0: 
        annotations.markIdle(uid,  id_session, payload["idle"])        
    if "__return" in payload and cid != 0:
        R = payload["__return"]
        if R["type"] == "newNotesOnFile": 
            id_source = R["a"]["id_source"]
            if auth.canReadFile(uid, id_source):
                output["locations"], output["comments"], output["threadmarks"] = annotations.getCommentsByFile(id_source, uid, previous_activity)
        elif R["type"] == "newPending":
            #for now, we retrieve all the pending stuff. 
            output = annotations.getPending(uid, payload)
    return UR.prepare_response(output)
Ejemplo n.º 3
0
def getNotes(payload, req):
    uid = UR.getUserId(req)
    output = {}
    if "file" in payload: #access by file
        after = payload.get("after", None)
        id_source = payload["file"]
        if auth.canReadFile(uid, id_source):
            #output["notes"] = annotations.getNotesByFile(id_source, uid)
            output["file"] = id_source
            output["locations"], output["comments"] = annotations.getCommentsByFile(id_source, uid, after)
            #TODO: 
            #output["links"] = annotations.get_links(uid, {"id_source": id_source})
            output["seen"] = annotations.getSeenByFile(id_source, uid)
        else:
            return UR.prepare_response({}, 1, "NOT ALLOWED")
    return UR.prepare_response(output)
Ejemplo n.º 4
0
def getNotes(payload, req):
    uid = UR.getUserId(req)
    output = {}
    if "file" in payload: #access by file
        after = payload.get("after", None)
        id_source = payload["file"]
        if auth.canReadFile(uid, id_source, req):
            #output["notes"] = annotations.getNotesByFile(id_source, uid)
            output["file"] = id_source
            output["locations"], output["comments"], output["threadmarks"] = annotations.getCommentsByFile(id_source, uid, after)
            #TODO: 
            #output["links"] = annotations.get_links(uid, {"id_source": id_source})
            output["seen"] = annotations.getSeenByFile(id_source, uid)
        else:
            return UR.prepare_response({}, 1, "NOT ALLOWED")
    return UR.prepare_response(output)
Ejemplo n.º 5
0
def log_history(payload, req):
    uid =  UR.getUserInfo(req, True).id
    if uid is None: 
        #SACHA TODO: LOG this.
        return UR.prepare_response({}, 1,  "NOT ALLOWED")
    cid = UR.CID
    if cid == 0:        
        return  UR.prepare_response({}, 1, "CID MOST BE NONZERO")
    session, previous_activity = annotations.markActivity(cid)
    if session is None: 
        return  UR.prepare_response({}, 1, "SESSION NOT FOUND")
    id_session = session.id
    output={}
    if "seen" in payload and cid != 0: 
        annotations.markCommentSeen(uid, id_session, payload["seen"])
    if "page" in payload and cid != 0: 
        annotations.markPageSeen(uid, id_session,  payload["page"])
    if "idle" in payload and cid != 0: 
        annotations.markIdle(uid,  id_session, payload["idle"]) 
    if "scrolling" in payload and cid != 0:         
        logger = logging.getLogger("scrolling")
        logger.info("%s|%s"%(id_session, payload["scrolling"]));
    if "__return" in payload and cid != 0:
        R = payload["__return"]
        if R["type"] == "newNotesOnFile": 
            id_source = R["a"]["id_source"]
            if auth.canReadFile(uid, id_source):
                output["locations"], output["html5locations"], output["comments"], output["threadmarks"] = annotations.getCommentsByFile(id_source, uid, previous_activity)
        elif R["type"] == "newPending":
            #for now, we retrieve all the pending stuff. 
            output = annotations.getPending(uid, payload)
    return UR.prepare_response(output)