Пример #1
0
 def put(self, name):
     data = Item.parser.parse_args()
     item = ItemModel.getItem(name)
     if item is None:
         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()
Пример #2
0
    def put(self, name):
        data = Item.parser.parse_args()

        item = ItemModel.find(name)
        if not item:
            item = ItemModel(name, **data)
        else:
            item.price = data["price"]
            item.store_id = data["store_id"]

        try:
            item.save()
            return item.json()
        except:
            return {"message": "An error occurred updating the item"}, 500