def getAllFuels(): if request.method == 'POST': return FuelHandler().insertFuel(request.json) else: if not request.args: return FuelHandler().getAllFuels() else: return FuelHandler().searchFuels(request.args)
def getAllFuels(): if request.method == 'POST': print("REQUEST: ", request.json) return FuelHandler().insertFuelJson(request.json) else: if not request.args: return FuelHandler().getAllFuels()
def getFuelById(fuid): if request.method == 'GET': return FuelHandler().getFuelByID(fuid) elif request.method == 'PUT': return FuelHandler().updateFuel(fuid, request.form) elif request.method == 'DELETE': return FuelHandler().deleteFuel(fuid) else: return jsonify(Error="Method not allowed."), 405
def getAllFuel(): if request.method == 'POST': print("REQUEST: ", request.json) return FuelHandler().insertFuelJson(request.json) else: if not request.args: return FuelHandler().getAllFuel() else: # change to searchFuel() once implemented in handlers return FuelHandler().searchFuel(request.args)
def getResourceFullInfo(self, resource_id): resource_dao = ResourceDAO() category = resource_dao.getResourceById(resource_id)[2] if category == 1: return FuelHandler().getFuelByResourceId(resource_id) elif category == 2: return FoodHandler().getFoodByResourceId(resource_id) elif category == 3: return MedicineHandler().getMedicineByResourceId(resource_id) elif category == 4: return ToolHandler().getToolByResourceId(resource_id) elif category == 5: return ClothHandler().getClothByResourceId(resource_id) elif category == 6: return HeavyEquipHandler().getHeavyEquipByResourceId(resource_id) elif category == 7: return WaterHandler().getWaterByResourceId(resource_id) elif category == 8: return MedDeviceHandler().getMedDeviceByResourceId(resource_id) elif category == 9: return BatteryHandler().getBatteryByResourceId(resource_id) elif category == 10: return GeneratorHandler().getGeneratorByResourceId(resource_id) elif category == 11: return IceHandler().getIceByResourceId(resource_id) else: return jsonify(Error="Invalid category"), 400
def getAllByType(self, type): print(type) if (type == 'babyfood'): return babyFoodHandler().getAllbabyFood() elif (type == 'dryfood'): return dryFoodHandler().getAlldryFood() elif (type == 'cannedfood'): return cannedFoodHandler().getAllcannedFood() elif (type == 'medication'): return MedicationHandler().getAllMedication() elif (type == 'batteries'): return BatteryHandler().getAllbattery() elif (type == 'clothing'): return ClothingHandler().getAllClothes() elif (type == 'heavyequipment'): return HeavyEquipmentHandler().getAllHeavyEquipment() elif (type == 'ice'): return IceHandler().getAllIce() elif (type == 'tools'): return PowerToolsHandler().getAllTools() elif (type == 'fuel'): return FuelHandler().getAllFuel() elif (type == 'medicaldevices'): return MedicalDevicesHandler().getAllMedicalDevices() elif (type == 'powergenerator'): return PowerGeneratorHandler().getAllPowerGenerator() elif (type == 'hygiene'): return HygieneHandler().getAllHygiene() elif (type == 'water'): return WaterHandler().getAllWater() else: return MedicationHandler().getAllMedication()
def getHandler(self, type): if (type == 'babyfood'): return babyFoodHandler() elif (type == 'dryfood'): return dryFoodHandler() elif (type == 'cannedfood'): return cannedFoodHandler() elif (type == 'medication'): return MedicationHandler() elif (type == 'batteries'): return BatteryHandler() elif (type == 'clothing'): return ClothingHandler() elif (type == 'heavyequipment'): return HeavyEquipmentHandler() elif (type == 'ice'): return IceHandler() elif (type == 'powertools'): return PowerToolsHandler() elif (type == 'fuel'): return FuelHandler() elif (type == 'medicaldevices'): return MedicalDevicesHandler() elif (type == 'powergenerator'): return PowerGeneratorHandler() elif (type == 'hygiene'): return HygieneHandler() elif (type == 'water'): return WaterHandler() else: return MedicationHandler()
def getAllResourceDetails(resourceid): categoryname = CategoriesHandler().getCategoryByResourceID(resourceid) if categoryname == "BabyFood": return BabyFoodHandler().getBabyFoodByResourceID(resourceid) elif categoryname == "Batteries": return BatteriesHandler().getBatteriesByResourceID(resourceid) elif categoryname == "CannedFood": return CannedFoodHandler().getCFoodByResourceID(resourceid) elif categoryname == "Clothing": return ClothingHandler().getClothingByResourceID(resourceid) elif categoryname == "DryFood": return DryFoodHandler().getDryFoodByResourceID(resourceid) elif categoryname == "Fuel": return FuelHandler().getFuelByResourceID(resourceid) elif categoryname == "Generators": return GeneratorsHandler().getGeneratorsByResourceID(resourceid) elif categoryname == "HeavyEquipment": return HeavyEquipmentHandler().getHeavyEquipmentByResourceID( resourceid) elif categoryname == "Ice": return IceHandler().getIceByResourceID(resourceid) elif categoryname == "MedicalEquipment": return MedicalEquipmentHandler().getMedicalEquipmentByResourceID( resourceid) elif categoryname == "Medication": return MedicineHandler().getMedicineByResourceID(resourceid) elif categoryname == "Parts": return PartsHandler().getPartsByResourceID(resourceid) elif categoryname == "Tools": return ToolsHandler().getToolsByResourceID(resourceid) elif categoryname == "Water": return WaterHandler().getWaterByResourceID(resourceid)
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)
def getAllReservedFuelsBySupplierId(supplier_id): return FuelHandler().getAllReservedFuelsBySupplierId(supplier_id)
def getAllReservedFuels(): return FuelHandler().getAllReservedFuels()
def getAllAvailableFuelsBySupplierId(supplier_id): return FuelHandler().getAllAvailableFuelsBySupplierId(supplier_id)
def getAllAvailableFuels(): return FuelHandler().getAllAvailableFuels()
def getFuelsBySupplierId(supplier_id): return FuelHandler().getFuelsBySupplierId(supplier_id)
def getFuelAddress(fuel_id): return FuelHandler().getFuelAddress(fuel_id)