def deleteTool(self, toolid): dao = ToolsDAO() if not dao.getToolsById(toolid): return jsonify(Error="Tool not found"), 404 else: dao.delete(toolid) return jsonify(DeleteStatus="OK"), 200
def getToolByID(self, toolid): dao = ToolsDAO() row = dao.getToolsById(toolid) if not row: return jsonify(Error="Tool not found"), 404 else: tool = self.build_tools_dict(row) return jsonify(Tool=tool)
def updateTool(self, toolid, form): dao = ToolsDAO() if not dao.getToolsById(toolid): return jsonify(Error="Tool not found"), 404 else: resourceid = form['resourceid'] toolmaterial = form['toolmaterial'] toolcolor = form['toolcolor'] tooldescription = form['tooldescription'] if toolmaterial and toolcolor and tooldescription: dao.update(toolid, toolmaterial, toolcolor, tooldescription) result = self.build_tools_attributes(toolid, resourceid, toolmaterial, toolcolor, tooldescription) return jsonify(Tool=result), 200 else: return jsonify( Error="Unepected attributes un put request"), 404