def put(self, name): data = Item.parser.parse_args() item = ItemModel.find_by_name(name) if item is None: item = ItemModel(name, **data) else: item.price = data["price"] item.store_id = data["store_id"] item.save_to_db() return item.json()
def put(self, name): data = Item.parser.parse_args() item = ItemModel.find_by_name(name) if not item: item = ItemModel(name, data['price'], data['store_id']) else: item.price = data['price'] item.store_id = data['store_id'] item.save_to_db() return item.json(), 201
def put(self, name): item = ItemModel.find_by_name(name) data = Item.parser.parse_args() if item is None: #same as below// item = ItemModel(name, data['price'], data['store_id']) item = ItemModel(name, **data) else: item.price = data['price'] item.store_id = data['store_id'] item.save_to_db() return item.json(), 201