def getResourceIDByWaterID(self, Waterid): dao = WaterDAO() row = dao.getResourceIDByWaterID(Waterid) if not row: return jsonify(Error="Water Not Found "), 404 else: Water = self.build_water_dict(row) return jsonify(Water=Water)
def updateResourceJson(self, waterid, json): dao = WaterDAO() if not dao.getWaterById(waterid): return jsonify(Error="Resource not found"), 404 else: watersize = json['watersize'] waterdescription = json['waterdescription'] if watersize and waterdescription: dao.update(waterid, watersize, waterdescription) resourceid = dao.getResourceIDByWaterID(waterid) result = self.build_water_attributes(waterid, resourceid, watersize, waterdescription) return jsonify(Water=result), 200 else: return jsonify( Error="Unexpected attributes in post request"), 400
def updateResource(self, waterid, form): dao = WaterDAO() if not dao.getWaterById(waterid): return jsonify(Error="Resource not found"), 404 else: if (len(form) != 2): return jsonify(Error="Malformed update request") else: watersize = form['watersize'] waterdescription = form['waterdescription'] if watersize and waterdescription: dao.update(waterid, watersize, waterdescription) resourceid = dao.getResourceIDByWaterID(waterid) result = self.build_water_attributes( waterid, resourceid, watersize, waterdescription) return jsonify(Water=result), 400 else: return jsonify( Error="Unexpected attributes in update request"), 404