Beispiel #1
0
    def put(self, name):
        data = Item.parser.parse_args()

        item = ItemModel.find_by_name(name)

        if item is None:
            try:
                item = ItemModel(name, **data)
            except:
                {
                    'message':
                    'An error occurred attempting to insert the item into the database'
                }, 500  # Internal Server Error
        else:
            try:
                item.price = data['price']
                item.store_id = data['store_id']
            except:
                {
                    'message':
                    'An error occurred attempting to update the item in the database'
                }, 500  # Internal Server Error

        item.save_to_db()

        return item.json()
Beispiel #2
0
 def put(self, name):
     data = Item.parser.parse_args()
     item = ItemModel.find_by_name(name)
     if item is None:
         item = ItemModel(name, data['price'])
     else:
         item.price = data['price']
     item.save_to_DB()
     return item.json()
Beispiel #3
0
    def put(self, name):
        # data = request.get_json()
        data = Item.parser.parse_args()
        item = ItemModel.findByName(name)

        if item is None:
            item = ItemModel(name, data['price'])
        else:
            item.price = data['price']
        item.save_to_db()
        return item.json()
Beispiel #4
0
    def put(self, name):
        data = Item.parser.parse_args()

        item = ItemModel.find_by_name(name)

        if item is None:
            item = ItemModel(name, **data) #data['price'], data['store_id']
        else:
            item.price = data['price']

        item.save_to_db()
        return item.json()
    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.save_to_db()
        return item.json()
Beispiel #6
0
    def put(self, name):
        request_data = Item.parser.parse_args()
        item = ItemModel.find_by_name(
            name)  #next(filter(lambda x: x['name'] == name, items),None)
        if item is None:
            item = ItemModel(
                name, **
                request_data)  #request_data['price'], request_data['store_id']
        else:
            item.price = request_data['price']
        item.save_db()

        return item.json()