Ejemplo n.º 1
0
def getAllResource():
    if request.method == 'POST':
        print("REQUEST: ", request.json)
        # return PartHandler().insertPartJson(request.json)
    else:
        if not request.args:
            return ResourceHandler().getAllResource()
        else:
            return ResourceHandler().searchResource(request.args)
Ejemplo n.º 2
0
def getResourceById(pid):
    if request.method == 'GET':
        return ResourceHandler().getResourceById(pid)
    elif request.metod == 'PUT':
        return ResourceHandler().updatePart(pid, request.form)
    elif request.method == 'DELETE':
        return ResourceHandler().deletePart(pid)
    else:
        return jsonify(Error="Method not allowed."), 405
Ejemplo n.º 3
0
def getAvailableResources():
    if request.method == 'POST':
        return ResourceHandler().insertAvailableResource(request.args)
    if request.method == 'PUT':
        return ResourceHandler().updateInventory(request.args)
    if request.method == 'DELETE':
        return ResourceHandler().hideResource(request.args)
    if not request.args:
        return ResourceHandler().getAvailableResources()
    return ResourceHandler().getAvailableResourcesByCity(request.args)
Ejemplo n.º 4
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
Ejemplo n.º 5
0
def getResourceById(rid):
    if request.method == 'GET':
        return ResourceHandler().getResourceById(rid)

    elif request.method == 'PUT':
        return ResourceHandler().insertResourceBySupplierIdJson(
            rid, request.json)  #by resource id and supplier id

    elif request.method == 'DELETE':
        return ResourceHandler().deleteResource(rid)

    else:
        return jsonify(Error="Method not allowed"), 405
Ejemplo n.º 6
0
def getResourcesByTypeId(resource_type, resource_type_id):
    if request.method == 'GET':
        if resource_type == 'fuel':
            return FuelHandler().getFuelById(resource_type_id)
        if resource_type == 'ice':
            return IceHandler().getIceById(resource_type_id)
        if resource_type == 'clothing':
            return ClothingHandler().getClothesgById(resource_type_id)
        if resource_type == 'battery':
            return BatteryHandler().getBatteryById(resource_type_id)
        if resource_type == 'babyfood':
            return babyFoodHandler().getbabyFoodById(resource_type_id)
        if resource_type == 'cannedfood':
            return cannedFoodHandler().getcannedFoodById(resource_type_id)
        if resource_type == 'dryfood':
            return dryFoodHandler().getdryFoodById(resource_type_id)
        if resource_type == 'heavyequipment':
            return HeavyEquipmentHandler().getHeavyEquimentById(resource_type_id)
        if resource_type == 'medication':
            return MedicationHandler().getMedicationById(resource_type_id)
        if resource_type == 'tools':
            return PowerToolsHandler().getToolById(resource_type_id)
        if resource_type == 'water':
            return WaterHandler().getWaterById(resource_type_id)
        if resource_type == 'medicaldevices':
            return MedicalDevicesHandler().getMedicalDevicesById(resource_type_id)
        if resource_type == 'powergenerator':
            return PowerGeneratorHandler().getPowerGeneratorById(resource_type_id)
        if resource_type == 'hygiene':
            return HygieneHandler().getHygieneById(resource_type_id)

        else:
            return ResourceHandler().getAllByType(resource_type)
Ejemplo n.º 7
0
 def getResourcesByReservationId(self, reservation_id):
     reservation_dao = ReservationDAO()
     if not reservation_dao.getReservationById(reservation_id):
         return jsonify(Error="Reservation Not Found"), 404
     else:
         resources_list = []
         result_list = []
         resources_list = reservation_dao.getResourcesByReservationId(
             reservation_id)
         for row in resources_list:
             result = ResourceHandler().build_resource_dict(row)
             result_list.append(result)
         return jsonify(Resources=result_list)
Ejemplo n.º 8
0
def viewResourceAll():
    return ResourceHandler().getAll()
Ejemplo n.º 9
0
def getFreeResources():
    return ResourceHandler().getFreeResources()
Ejemplo n.º 10
0
def getResourceByName(name):
    return ResourceHandler().getResourceByName(name)
Ejemplo n.º 11
0
def viewResourceByKeyword(keyword):
    return ResourceHandler().getAllResourceByKeyword(keyword)
Ejemplo n.º 12
0
def getAnnouncementsByResourceCategory(category):
    return ResourceHandler().getAnnouncementsByResourceCategory(category)
Ejemplo n.º 13
0
def getResourcesInNeed():
    return ResourceHandler().getResourcesInNeed()
Ejemplo n.º 14
0
def viewRequestedById(request_id):
    return ResourceHandler().getResourceInRequest(request_id)
Ejemplo n.º 15
0
def getResourceAnnouncement():
    if request.method == 'GET':
        return ResourceHandler().getAnnouncement()
    else:
Ejemplo n.º 16
0
def getByType(resource_type, keyword):
    handler = ResourceHandler().getHandler(resource_type)

    return handler.getAllResourceByKeyword(keyword)
Ejemplo n.º 17
0
def getAvailablePerRegion():
    if request.method == 'GET':
        return ResourceHandler().getResourceAvailablePerRegion()
Ejemplo n.º 18
0
def getAllResources():
    if not request.args:
        return ResourceHandler().getAllResources()
    else:
        return ResourceHandler().search(request.args)
Ejemplo n.º 19
0
def viewCatalog():
    return ResourceHandler().getAll()
Ejemplo n.º 20
0
def viewAvailable():
    return ResourceHandler().getResourcesInStock()
Ejemplo n.º 21
0
def getAvailableResources():
    return ResourceHandler().getAvailableResources()
Ejemplo n.º 22
0
def getAllResources():
    if request.method == 'POST':
        return ResourceHandler().insertResource(request.args)
    if not request.args:
        return ResourceHandler().getAllResources()
    return ResourceHandler().searchResource(request.args)
Ejemplo n.º 23
0
def getAvailableResourcesByKeyword(keyword):
    return ResourceHandler().getResourcesByKeywordAndAvailability(keyword,False,True)
Ejemplo n.º 24
0
def getResourcesbyId(resource_id):
    return ResourceHandler().getResourceById(resource_id)
Ejemplo n.º 25
0
def getRequestsByResourceCategory(category):
    return ResourceHandler().getRequestsByResourceCategory(category)
Ejemplo n.º 26
0
def getTotalSalesByResourceID(rid):
    return ResourceHandler().getTotalSalesByResourceId(rid)
Ejemplo n.º 27
0
def getSuppliersByResourceName(name):
    return ResourceHandler().getSuppliersByResourceName(name)
Ejemplo n.º 28
0
def getResources(resource_type):
    if request.method == 'GET':
        return ResourceHandler().getAllByType(resource_type)
Ejemplo n.º 29
0
def searchAvailable(resource_type, search_keyword):
    return ResourceHandler().getAllByType(resource_type)
Ejemplo n.º 30
0
def getResourceByRid(Rid):
    return ResourceHandler().getResourceByRid(Rid)