def markNote(payload, req): uid = UR.getUserId(req) id_comment = payload["id_comment"] if not auth.canMark(uid,id_comment ): return UR.prepare_response({}, 1, "NOT ALLOWED") else: annotations.markNote(uid, payload); comments = annotations.getComment(id_comment,uid) locs, h5locs = annotations.getLocation(comments[int(id_comment)]["ID_location"]) p = {"locations":locs, "html5locations": h5locs, "marks": annotations.getMark(uid, payload), "comments": comments} return UR.prepare_response(p)
def editNote(payload, req): uid = UR.getUserId(req) if not auth.canEdit(uid, payload["id_comment"]): return UR.prepare_response({}, 1, "NOT ALLOWED") else: annotations.editNote(payload) #for mark in payload["marks"]: # annotations.markNote(uid, {"action": payload["marks"][mark], "id_comment": payload["id_comment"]}) return UR.prepare_response({"comments": annotations.getComment(payload["id_comment"], uid), "marks": annotations.getMark(uid,{"id_comment": payload["id_comment"]}) })
def editNote(payload, req): uid = UR.getUserId(req) if not auth.canEdit(uid, payload["id_comment"]): return UR.prepare_response({}, 1, "NOT ALLOWED") else: annotations.editNote(payload) #for mark in payload["marks"]: # annotations.markNote(uid, {"action": payload["marks"][mark], "id_comment": payload["id_comment"]}) return UR.prepare_response({ "comments": annotations.getComment(payload["id_comment"], uid), "marks": annotations.getMark(uid, {"id_comment": payload["id_comment"]}) })
def saveNote(payload, req): uid = UR.getUserId(req) if not auth.canAnnotate(uid, payload["id_ensemble"]): return UR.prepare_response({}, 1, "NOT ALLOWED") payload["id_author"] = uid retval = {} a = annotations.addNote(payload) #for mark in payload["marks"]: # annotations.markNote(uid, {"action": payload["marks"][mark], "id_comment": a["id_comment"]}) if "id_location" in a: retval["locations"] = annotations.getLocation(a["id_location"]) retval["comments"] = annotations.getComment(a["id_comment"], uid) retval["marks"] = annotations.getMark(uid,{"id_comment": a["id_comment"]}) return UR.prepare_response(retval)
def saveNote(payload, req): uid = UR.getUserId(req) if not auth.canAnnotate(uid, payload["id_ensemble"]): return UR.prepare_response({}, 1, "NOT ALLOWED") payload["id_author"] = uid retval = {} a = annotations.addNote(payload) #for mark in payload["marks"]: # annotations.markNote(uid, {"action": payload["marks"][mark], "id_comment": a["id_comment"]}) if "id_location" in a: retval["locations"] = annotations.getLocation(a["id_location"]) retval["comments"] = annotations.getComment(a["id_comment"], uid) retval["marks"] = annotations.getMark(uid, {"id_comment": a["id_comment"]}) return UR.prepare_response(retval)