예제 #1
0
파일: views.py 프로젝트: pwilkins/nbproject
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)
예제 #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"] = annotations.getCommentsByFile(id_source, uid, previous_activity)             
    return UR.prepare_response(output)
예제 #3
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)
예제 #4
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)