def getRequestsByResourceId(self, resid): requests_dao = RequestData() row = requests_dao.getRequestById(resid) if not row: return jsonify(Error="Request Not Found"), 404 else: result = self.build_request_dict(row) return jsonify(Request=result)
def getAllRequestedResourcesByKeyword(self, keyword): requests_dao = RequestData() requests_list = requests_dao.getAllRequestedResourcesByKeyword(keyword) result_list = [] for row in requests_list: result = self.build_requested_resources_dict(row) result_list.append(result) return jsonify(Requests=result_list)
def getRequestsInfoByVictimId(self, vid): requests_dao = RequestData() row = requests_dao.getRequestsInfoByVictimId(vid) if not row: return jsonify(Error="Request Not Found"), 404 else: result = self.build_request_info_dict(row) return jsonify(Request=result)
def getAllRequests(self): requests_dao = RequestData() requests_list = requests_dao.getAllRequests() result_list = [] for row in requests_list: result = self.build_request_dict(row) result_list.append(result) return jsonify(Requests=result_list)
def insertRequest(self, form): if form and len(form) == 3: date_submited = form['date_submited'] resource_id = form['resource_id'] victim_id = form['victim_id'] if date_submited and resource_id and victim_id: dao = RequestData() request_id = dao.insert(date_submited, resource_id, victim_id) result = {} result["request_id"] = request_id result["date_submited"] = date_submited result["resource_id"] = resource_id result["victim_id"] = victim_id return jsonify(Request=result), 201 else: return jsonify(Error="Malformed post request1") else: return jsonify(Error="Malformed post request2")