def conferences_get_read_markings(conf_no): """Return read-markings. Mostly used with *unread=true* to return unread texts in the given conference. .. rubric:: Request :: GET /conferences/14506/read-markings/?unread=true HTTP/1.1 .. rubric:: Response :: HTTP/1.1 200 OK { "rms": [ { "text_no": 19791715, "unread": true, "conf_no": 14506 }, { "text_no": 19791718, "unread": true, "conf_no": 14506 } ] } .. rubric:: Example :: curl -b cookies.txt -c cookies.txt -v \\ -X GET http://localhost:5001/conferences/14506/read-markings/?unread=true """ unread = get_bool_arg_with_default(request.args, 'unread', False) if unread: # TODO: return local_text_no as well return jsonify(rms=[ dict(conf_no=conf_no, text_no=text_no, unread=unread) for text_no in g.ksession.\ get_unread_in_conference(conf_no) ]) else: raise NotImplementedError()
def conferences_get(conf_no): """Get information about a specific conference. ======= ======= ================================================================= Key Type Values ======= ======= ================================================================= micro boolean :true: (Default) Return micro conference information (`UConference <http://www.lysator.liu.se/lyskom/protocol/11.1/protocol-a.html#Conferences>`_) which causes less load on the server. :false: Return full conference information. ======= ======= ================================================================= .. rubric:: Request :: GET /conferences/14506 HTTP/1.1 .. rubric:: Responses With micro=true:: HTTP/1.0 200 OK { "highest_local_no": 1996, "nice": 77, "type": { "forbid_secret": 0, "allow_anonymous": 1, "rd_prot": 1, "secret": 0, "letterbox": 1, "original": 0, "reserved3": 0, "reserved2": 0 }, "name": "Oskars Testperson", "conf_no": 14506 } With micro=false:: HTTP/1.0 200 OK { "super_conf": { "conf_name": "", "conf_no": 0 }, "creator": { "pers_no": 14506, "pers_name": "Oskars Testperson" }, "no_of_texts": 1977, "no_of_members": 1, "creation_time": "2012-04-28 19:49:11", "permitted_submitters": { "conf_name": "", "conf_no": 0 }, "conf_no": 14506, "last_written": "2012-07-31 00:00:11", "keep_commented": 77, "name": "Oskars Testperson", "type": { "forbid_secret": 0, "allow_anonymous": 1, "rd_prot": 1, "secret": 0, "letterbox": 1, "original": 0, "reserved3": 0, "reserved2": 0 }, "first_local_no": 20, "expire": 0, "msg_of_day": 0, "supervisor": { "conf_name": "Oskars Testperson", "conf_no": 14506 }, "presentation": 0, "nice": 77 } Conference does not exist:: HTTP/1.0 404 NOT FOUND { TODO: error stuff } .. rubric:: Example :: curl -b cookies.txt -c cookies.txt -v \\ -X GET http://localhost:5001/conferences/14506?micro=true """ try: micro = get_bool_arg_with_default(request.args, 'micro', True) return jsonify( to_dict(g.ksession.get_conference(conf_no, micro), True, g.ksession)) except kom.UndefinedConference as ex: return error_response(404, kom_error=ex)
def conferences_list(): """Get list of conferences. Query parameters: ======= ======= ================================================================= Key Type Values ======= ======= ================================================================= unread boolean :true: Return conferences with unread texts in. :false: (Default) *Not implemented.* micro boolean :true: (Default) Return micro conference information (`UConference <http://www.lysator.liu.se/lyskom/protocol/11.1/protocol-a.html#Conferences>`_) which causes less load on the server. :false: Return full conference information. ======= ======= ================================================================= .. rubric:: Request :: GET /conferences/?unread=true HTTP/1.0 .. rubric:: Responses With micro=true:: HTTP/1.0 200 OK { "confs": [ { "highest_local_no": 1996, "nice": 77, "type": { "forbid_secret": 0, "allow_anonymous": 1, "rd_prot": 1, "secret": 0, "letterbox": 1, "original": 0, "reserved3": 0, "reserved2": 0 }, "name": "Oskars Testperson", "conf_no": 14506 } ] } With micro=false:: HTTP/1.0 200 OK { "confs": [ { "super_conf": { "conf_name": "", "conf_no": 0 }, "creator": { "pers_no": 14506, "pers_name": "Oskars Testperson" }, "no_of_texts": 1977, "no_of_members": 1, "creation_time": "2012-04-28 19:49:11", "permitted_submitters": { "conf_name": "", "conf_no": 0 }, "conf_no": 14506, "last_written": "2012-07-31 00:00:11", "keep_commented": 77, "name": "Oskars Testperson", "type": { "forbid_secret": 0, "allow_anonymous": 1, "rd_prot": 1, "secret": 0, "letterbox": 1, "original": 0, "reserved3": 0, "reserved2": 0 }, "first_local_no": 20, "expire": 0, "msg_of_day": 0, "supervisor": { "conf_name": "Oskars Testperson", "conf_no": 14506 }, "presentation": 0, "nice": 77 } ] } .. rubric:: Example :: curl -b cookies.txt -c cookies.txt -v \\ -X GET -H "Content-Type: application/json" \\ http://localhost:5001/conferences/?unread=trueµ=false """ micro = get_bool_arg_with_default(request.args, 'micro', True) unread = get_bool_arg_with_default(request.args, 'unread', False) if unread: return jsonify(confs=to_dict(g.ksession.get_conferences(unread, micro), True, g.ksession)) else: abort(400) # nothing else is implemented
def conferences_get(conf_no): """Get information about a specific conference. ======= ======= ================================================================= Key Type Values ======= ======= ================================================================= micro boolean :true: (Default) Return micro conference information (`UConference <http://www.lysator.liu.se/lyskom/protocol/11.1/protocol-a.html#Conferences>`_) which causes less load on the server. :false: Return full conference information. ======= ======= ================================================================= .. rubric:: Request :: GET /conferences/14506 HTTP/1.1 .. rubric:: Responses With micro=true:: HTTP/1.0 200 OK { "highest_local_no": 1996, "nice": 77, "type": { "forbid_secret": 0, "allow_anonymous": 1, "rd_prot": 1, "secret": 0, "letterbox": 1, "original": 0, "reserved3": 0, "reserved2": 0 }, "name": "Oskars Testperson", "conf_no": 14506 } With micro=false:: HTTP/1.0 200 OK { "super_conf": { "conf_name": "", "conf_no": 0 }, "creator": { "pers_no": 14506, "pers_name": "Oskars Testperson" }, "no_of_texts": 1977, "no_of_members": 1, "creation_time": "2012-04-28 19:49:11", "permitted_submitters": { "conf_name": "", "conf_no": 0 }, "conf_no": 14506, "last_written": "2012-07-31 00:00:11", "keep_commented": 77, "name": "Oskars Testperson", "type": { "forbid_secret": 0, "allow_anonymous": 1, "rd_prot": 1, "secret": 0, "letterbox": 1, "original": 0, "reserved3": 0, "reserved2": 0 }, "first_local_no": 20, "expire": 0, "msg_of_day": 0, "supervisor": { "conf_name": "Oskars Testperson", "conf_no": 14506 }, "presentation": 0, "nice": 77 } Conference does not exist:: HTTP/1.0 404 NOT FOUND { TODO: error stuff } .. rubric:: Example :: curl -b cookies.txt -c cookies.txt -v \\ -X GET http://localhost:5001/conferences/14506?micro=true """ try: micro = get_bool_arg_with_default(request.args, 'micro', True) return jsonify(to_dict(g.ksession.get_conference(conf_no, micro), True, g.ksession)) except kom.UndefinedConference as ex: return error_response(404, kom_error=ex)