def deleteResource(self, r_id): dao = ResourceDAO() if not dao.getResourceById(r_id): return jsonify(Error = "Resource not found."), 404 else: dao.delete(r_id) return jsonify(DeleteStatus = "OK"), 200
def deleteBaterry(self, battery_id): battery_dao = BatteryDAO() if not battery_dao.getBatteryById(battery_id): return jsonify(Error = "Battery not found."), 404 else: resource_id = battery_dao.delete(battery_id) res_dao = ResourceDAO() res_dao.delete(resource_id) return jsonify(DeleteStatus = "OK"), 200
def deleteMedDevice(self, med_device_id): med_device_dao = MedDeviceDAO() if not med_device_dao.getMedDeviceById(med_device_id): return jsonify(Error = "Medical Device not found."), 404 else: resource_id = med_device_dao.delete(med_device_id) resource_dao = ResourceDAO() resource_dao.delete(resource_id) return jsonify(DeleteStatus = "OK"), 200
def deleteWater(self, water_id): water_dao = WaterDAO() if not water_dao.getWaterById(water_id): return jsonify(Error="Water not found."), 404 else: resource_id = water_dao.delete(water_id) resource_dao = ResourceDAO() resource_dao.delete(resource_id) return jsonify(DeleteStatus="OK"), 200
def deleteFuel(self, fuel_id): fuel_dao = FuelDAO() if not fuel_dao.getFuelById(fuel_id): return jsonify(Error="Fuel not found."), 404 else: resource_id = fuel_dao.delete(fuel_id) resource_dao = ResourceDAO() resource_dao.delete(resource_id) return jsonify(DeleteStatus="OK"), 200
def deleteIce(self, ice_id): ice_dao = IceDAO() res_dao = ResourceDAO() if not ice_dao.getIceById(ice_id): return jsonify(Error = "Ice not found."), 404 else: resource_id = ice_dao.delete(ice_id) res_dao.delete(resource_id) return jsonify(DeleteStatus = "OK"), 200
def deleteFood(self, food_id): food_dao = FoodDAO() if not food_dao.getFoodById(food_id): return jsonify(Error="Food not found."), 404 else: resource_id = food_dao.delete(food_id) resource_dao = ResourceDAO() resource_dao.delete(resource_id) return jsonify(DeleteStatus="OK"), 200
def deleteTool(self, tool_id): tool_dao = ToolDAO() if not tool_dao.getToolById(tool_id): return jsonify(Error = "Tool not found."), 404 else: resource_id = tool_dao.delete(tool_id) resource_dao = ResourceDAO() resource_dao.delete(resource_id) return jsonify(DeleteStatus = "OK"), 200
def deleteGenerator(self, generator_id): generator_dao = GeneratorDAO() if not generator_dao.getGeneratorById(generator_id): return jsonify(Error="Generator not found."), 404 else: resource_id = generator_dao.delete(generator_id) res_dao = ResourceDAO() res_dao.delete(resource_id) return jsonify(DeleteStatus="OK"), 200
def deleteHeavyEquip(self, hequip_id): hequip_dao = HeavyEquipDAO() if not hequip_dao.getHeavyEquipById(hequip_id): return jsonify(Error="Heavy Equipment not found."), 404 else: resource_id = hequip_dao.delete(hequip_id) resource_dao = ResourceDAO() resource_dao.delete(resource_id) return jsonify(DeleteStatus="OK"), 200
def deleteCloth(self, cloth_id): cloth_dao = ClothDAO() if not cloth_dao.getClothById(cloth_id): return jsonify(Error="Cloth not found."), 404 else: resource_id = cloth_dao.delete(cloth_id) resource_dao = ResourceDAO() resource_dao.delete(resource_id) return jsonify(DeleteStatus="OK"), 200
return jsonify(Error = "Resource Not Found"), 404 else: resource = form['resource'] if resource: dao.update(rsid, resource) result = self.build_resource_attributes(rsid, resource) return jsonify(Resource = result), 200 else: return jsonify(Error = "Unexpected attributes in update request"), 400 ***def deleteResource(self, rsid): dao = ResourceDAO() if not dao.getResourceById(rsid): return jsonify(Error = "Resource Not Found"), 404 else: dao.delete(rsid) return jsonify(DeleteStatus = "OK"), 200 def getResourcesByCityName(self, cname): pass def searchResourcesByCityName(self, cname, args): if not CityDAO().getCityByName(cname): return jsonify(Error = "City Not Found"), 404 else: rname = args.get('rname') r_changed_date = args.get('r_changed_date') rqty = args.get('rqty') rprice = args.get('rprice') r_supply_date = args.get('r_supply_date') dao = ResourceDAO()