def patch_reserve_fsmt(document_id): success = False inputs = FsmtJsonInputs(request) if not inputs.validate(): response = jsonify(success=False, errors=inputs.errors), 400 else: data = request.get_json() document = dao.MbomDocument(pool) if data['curr_fsmt'] == 'COMMITTED': success = document.commit(document_id) response = jsonify(success=success, message="document commited"), 200 elif data['curr_fsmt'] == 'DECOMMITTED': success = document.decommit(document_id) response = jsonify(success=success, message="document decommited"), 200 else: return jsonify(success=success, errors="incorrect fsmt"), 400 if not success: response = jsonify(success=False, errors=document.errors), 400 if not response: response = jsonify(success=success, message="unexpected error"), 400 return response
def patch_reserve_body(document_id): data = request.get_json() if data: d = dao.MbomDocument(pool) d.from_dict(data) d.reinit(document_id) return jsonify(str(document_id)) else: return '', 400
def del_reserve(document_id): document = dao.MbomDocument(pool) success = document.delete(document_id) if success: response = ('', 204) else: response = jsonify(success=False, errors=document.errors), 400 return response
def post_reserve(): success = False document_id = None inputs = OutboundDocumentJsonInputs(request) if not inputs.validate(): response = jsonify(success=success, errors=inputs.errors), 400 return response else: data = request.get_json() document = dao.MbomDocument(pool) document.from_dict(data) document_id = document.init() if document_id: success = True response = jsonify( success=success, message="document id=[{0}] created".format(document_id)), 200 else: response = jsonify(success=success, errors=document.errors), 400 return response
def get_reserve(document_id): document = dao.MbomDocument(pool, document_id) return jsonify(document.to_dict())