def patch_issue_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.Issue(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_issues_body(document_id): data = request.get_json() if data: d = dao.Issue(pool) d.from_dict(data) d.reinit(document_id) return jsonify(str(document_id)) else: return '', 400
def del_issue(document_id): document = dao.Issue(pool) success = document.delete(document_id) if success: response = ('', 204) else: response = jsonify(success=False, errors=document.errors), 400 return response
def post_issue(): 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.Issue(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_issue(document_id): document = dao.Issue(pool, document_id) return jsonify(document.to_dict())