def updateResourceJson(self, Generatorid, json): dao = GeneratorsDAO() if not dao.getGeneratorsById(Generatorid): return jsonify(Error="Generator not found."), 404 else: generatorbrand = json['generatorbrand'] generatortype = json['generatortype'] generatordescription = json['generatordescription'] resourceid = json['resourceid'] if generatorbrand and generatortype and generatordescription and resourceid: dao.update(Generatorid, generatorbrand, generatortype, generatordescription, resourceid) resourceid = dao.getResourceIDByGeneratorID(Generatorid) result = self.build_generators_attributes(Generatorid, generatorbrand, generatortype, generatordescription, resourceid) return jsonify(Generator=result), 400 else: return jsonify(Error="Unexpected attributes in update request"), 400
def updateResource(self, Generatorid, form): dao = GeneratorsDAO() if not dao.getBatteriesById(Generatorid): return jsonify(Error="Generator not found."), 404 else: if len(form) != 4: return jsonify(Error="Malformed update request") else: generatorbrand = form['generatorbrand'] generatortype = form['generatortype'] generatordescription = form['generatordescription'] resourceid = form['resourceid'] if generatorbrand and generatortype and generatordescription and resourceid: dao.update(Generatorid, generatorbrand, generatortype, generatordescription, resourceid) resourceid = dao.getResourceIDByGeneratorID(Generatorid) result = self.build_generators_attributes(Generatorid, generatorbrand, generatortype, generatordescription, resourceid) return jsonify(Generator=result), 400 else: return jsonify(Error="Unexpected attributes in update request"), 400