def getAllRequests(): if request.method == 'POST': return RequestHandler().insertRequest(request.args) else: if not request.args: return RequestHandler().getAllRequest() return RequestHandler().searchRequest(request.args)
def getAllRequest(): if request.method == 'POST': return RequestHandler().insert_request(request.form) else: if not request.args: return RequestHandler().getAllRequest() else: return RequestHandler().searchProductByRequests(request.args)
def getRequest(reqid): if request.method == 'GET': RequestHandler.getRequestByID(reqid) elif request.method == 'PUT': return RequestHandler().updateRequest(reqid, request.args) elif request.method == 'DELETE': return RequestHandler().deleteRequest(reqid) else: return jsonify(Error="Method not allowed."), 405
def get_request_by_id(rid): if request.method == 'GET': return RequestHandler().get_request_by_id(rid) elif request.method == 'PUT': return RequestHandler().update_request(rid, request.json) elif request.method == 'DELETE': return RequestHandler().delete_request(rid) else: return jsonify(message="Method not allowed."), 405
def requestResource(consumer_id, resource_type , resource_keyword): handler = RequestHandler() resp =handler.insert(resource_keyword , resource_type , consumer_id) print(resp[1]) if(resp[0] == True): #found match , return order return OrderHandler().getOrderById(resp[1]) return RequestHandler().getRequestById(resp[1])
def getRequestByID(req_id): if request.method == 'GET': return RequestHandler().getRequestByID(req_id) elif request.method == 'PUT': return RequestHandler().putRequestByID(request.form, req_id) elif request.method == 'DELETE': return RequestHandler().deleteRequestByID(req_id) else: return jsonify(Error="Method not allowed"), 405
def getAllRequest(): if request.method == 'POST': print("REQUEST: ", request.json) return RequestHandler().insertRequestJson(request.json) else: if not request.args: return RequestHandler().getAllRequest() else: return RequestHandler().searchRequest(request.args)
def get_all_or_create_requests(): if request.method == 'GET': supply_name = request.args.get('supply', None) status = request.args.get('status', None) if supply_name: return RequestHandler.get_all_requests(supply_name=supply_name) elif status: return RequestHandler.get_all_requests(status=status) return RequestHandler().get_all_requests() elif request.method == 'POST': return RequestHandler().create_request(request.json) else: return jsonify(message="Method not allowed."), 405
def insertResource(resource_type,supplier_id): if request.method == 'GET': return ResourceHandler().getAllByType(resource_type) if request.method == 'POST': jsonfo = request.json tbr = ResourceHandler().getHandler(resource_type).insert(jsonfo,supplier_id) RequestHandler().checkMa(jsonfo['resource_name'] , jsonfo['resource_description']) return tbr
def getRequestsByVictimId(victim_id): return RequestHandler().getRequestsInfoByVictimId(victim_id)
def getAllRequest(): if request.method == 'POST': return RequestHandler().insertRequest(request.form.to_dict()) else:
def getAllCreditCards(): if request.method == 'POST': return CreditCardHandler().insertCreditCard(json.loads(request.form.to_dict()) else: if not request.args: return CreditCardHandler().getAllCreditCards() # works phase3 @app.route('/DisasterApp/DisasterVictim/Request', methods=['GET', 'POST']) def getAllRequest(): if request.method == 'POST': return RequestHandler().insertRequest(request.form.to_dict()) else: if not request.args: return RequestHandler().getAllRequests() else: return RequestHandler().searchRequests(request.args) #Credit Card Update - funciona phase3 @app.route('/DisasterApp/CreditCard/<int:credit_card_id>', methods=['GET','PUT']) def getCreditCardById(credit_card_id): if request.method == 'GET': return CreditCardHandler().getCreditCardById(credit_card_id) elif request.method == 'PUT': return CreditCardHandler().updateCreditCard(credit_card_id, request.form.to_dict()) else: return jsonify(Error="Method not allowed."), 405 #Get Transaction of a Resource - funciona @app.route('/DisasterApp/Request_Completed/<int:resource_id>', methods=['GET']) def getRequestCompletedByResourceId(resource_id): if request.method == 'GET': return RequestCompletedHandler().getSaleRequestCompletedByResourceId(resource_id) else: return jsonify(Error="Method not allowed."), 405 # NOT TESTED @app.route('/DisasterApp/RequestCompleted/Sale/', methods=['GET', 'POST']) def getAllSaleRequestCompleted(): if request.method == 'POST': return RequestCompletedHandler().insertSale(request.form.to_dict()) else: if not request.args: return RequestCompletedHandler().getAllSales() @app.route('/DisasterApp/Resource/Announcement', methods=['GET']) def getResourceAnnouncement(): if request.method == 'GET': return ResourceHandler().getAnnouncement() else: return jsonify(Error="Method not allowed."), 405 @app.route('/DisasterApp/RequestCompleted/Donation/', methods=['GET', 'POST']) def getAllDonationRequestCompleted(): if request.method == 'POST': return RequestCompletedHandler().insertDonation(request.form.to_dict()) else: if not request.args: return RequestCompletedHandler().getAllDonation() if __name__ == '__main__': app.run(debug=True, port=5000)
def getRequestedResourcesByKeyword(keyword): return RequestHandler().getAllRequestedResourcesByKeyword(keyword)
def getNeededResources(): return RequestHandler().getAllRequestedResources()
def browseResourcesRequested(): return RequestHandler().browseResourcesRequested()
def getResourcestByRequests(): return RequestHandler().getResourcestByRequests()
def viewRequestedByKeyword(keyword): return RequestHandler().getAllRequestByKeyword(keyword)
def requestChange(r_id): if request.method == 'PUT': return RequestHandler().updateRequest(r_id, request.form) else: return jsonify(Error="Method not allowed."), 405
def getBuyerByRequestId(rq_id): return RequestHandler().getBuyerByRequestId(rq_id)
def getWeeklyReqs(): if request.method == 'GET': return RequestHandler().getRequestStatsPerWeek()
def getDailyReqs(): if request.method == 'GET': return RequestHandler().getRequestStatsPerDay()
def getAllRequest(): if not request.args: return RequestHandler().getAllRequest() else: return RequestHandler().searchProductByRequests(request.args)
def getLatestRequest(): return RequestHandler().getLatestRequest()
def searchRequestedById(request_id): return RequestHandler().getRequestById(request_id)
def getResourcestByRequestID(req_id): return RequestHandler().getResourcestByRequestID(req_id)
def getResourcesByRequestId(rq_id): return RequestHandler().getResourcesByRequestId(rq_id)
def getReqsPerRegion(): if request.method == 'GET': return RequestHandler().getRequestStatsPerRegion()
def getAvailableRequests(): return RequestHandler().getAvailableRequests()
def get_requests_by_user(uid): if request.method == 'GET': return RequestHandler().get_requests_by_user(uid) else: return jsonify(message="Method not allowed."), 405
def viewRequested(): return RequestHandler().getAllRequests()