def get(self, name): session_id = get_session_id(session, request) dao = DocumentReferenceDAO(session_id) found_dr = dao.get_document_reference(name) dao.close() resp = make_response(json_serialize(found_dr, session_id=session_id)) resp.headers['Content-Type'] = "application/json" return resp
def delete(self, name): session_id = get_session_id(session, request) dao = DocumentReferenceDAO(session_id) dao.delete_document_reference(name) dao.close() resp_dict = {'message': name + ' deleted'} resp = make_response(json_serialize(resp_dict), OK) resp.contenttype = 'application/json' return resp
def get(self): session_id = get_session_id(session, request) constraint_id = request.args.get('constraint_id', -1) dao = DocumentReferenceDAO(session_id) drs = dao.get_document_references(constraint_id=constraint_id) dao.close() resp = make_response(json_serialize(drs, session_id=session_id)) resp.headers['Content-Type'] = "application/json" return resp
def delete(self, name): session_id = get_session_id(session, request) dao = DocumentReferenceDAO(session_id) dao.delete_document_reference(name) dao.close() resp_dict = {'message': 'Document Reference successfully deleted'} resp = make_response(json_serialize(resp_dict), OK) resp.contenttype = 'application/json' return resp
def put(self, name): session_id = get_session_id(session, request) dao = DocumentReferenceDAO(session_id) upd_dr = dao.from_json(request) dao.update_document_reference(upd_dr, name) dao.close() resp_dict = {'message': upd_dr.name() + ' updated'} resp = make_response(json_serialize(resp_dict), OK) resp.contenttype = 'application/json' return resp
def put(self, name): session_id = get_session_id(session, request) dao = DocumentReferenceDAO(session_id) upd_dr = dao.from_json(request) dao.update_document_reference(upd_dr, name) dao.close() resp_dict = {'message': 'Document Reference successfully updated'} resp = make_response(json_serialize(resp_dict), OK) resp.contenttype = 'application/json' return resp
def post(self): session_id = get_session_id(session, request) dao = DocumentReferenceDAO(session_id) new_dr = dao.from_json(request) dao.add_document_reference(new_dr) dao.close() resp_dict = {'message': 'Document Reference successfully added'} resp = make_response(json_serialize(resp_dict, session_id=session_id), OK) resp.contenttype = 'application/json' return resp