Exemple #1
0
def getAllRequests():
    if request.method == 'POST':
        return RequestHandler().insertRequest(request.args)
    else:
        if not request.args:
            return RequestHandler().getAllRequest()
        return RequestHandler().searchRequest(request.args)
Exemple #2
0
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)
Exemple #3
0
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
Exemple #4
0
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
Exemple #5
0
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])
Exemple #6
0
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)
Exemple #8
0
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
Exemple #9
0
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()
Exemple #15
0
def browseResourcesRequested():
    return RequestHandler().browseResourcesRequested()
Exemple #16
0
def getResourcestByRequests():
    return RequestHandler().getResourcestByRequests()
Exemple #17
0
def viewRequestedByKeyword(keyword):
    return RequestHandler().getAllRequestByKeyword(keyword)
Exemple #18
0
def requestChange(r_id):
    if request.method == 'PUT':
        return RequestHandler().updateRequest(r_id, request.form)
    else:
        return jsonify(Error="Method not allowed."), 405
Exemple #19
0
def getBuyerByRequestId(rq_id):
    return RequestHandler().getBuyerByRequestId(rq_id)
Exemple #20
0
def getWeeklyReqs():
    if request.method == 'GET':
        return RequestHandler().getRequestStatsPerWeek()
Exemple #21
0
def getDailyReqs():
    if request.method == 'GET':
        return RequestHandler().getRequestStatsPerDay()
Exemple #22
0
def getAllRequest():
    if not request.args:
        return RequestHandler().getAllRequest()
    else:
        return RequestHandler().searchProductByRequests(request.args)
def getLatestRequest():
    return RequestHandler().getLatestRequest()
Exemple #24
0
def searchRequestedById(request_id):
    return RequestHandler().getRequestById(request_id)
Exemple #25
0
def getResourcestByRequestID(req_id):
    return RequestHandler().getResourcestByRequestID(req_id)
Exemple #26
0
def getResourcesByRequestId(rq_id):
    return RequestHandler().getResourcesByRequestId(rq_id)
Exemple #27
0
def getReqsPerRegion():
    if request.method == 'GET':
        return RequestHandler().getRequestStatsPerRegion()
Exemple #28
0
def getAvailableRequests():
    return RequestHandler().getAvailableRequests()
Exemple #29
0
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
Exemple #30
0
def viewRequested():
    return RequestHandler().getAllRequests()