Beispiel #1
0
def repryce(product_id):
    product = Product.get_by_id(product_id)

    product.price = float(request.form['price'])
    product.put()

    return '', 204
Beispiel #2
0
def get_by_id(product_id):
    product = Product.get_by_id(product_id)

    if not product:
        return 'Product id %s not found' % (product_id), 404

    return json.dumps(product.to_dict())
Beispiel #3
0
def add_quantity(product_id):
    product = Product.get_by_id(product_id)

    product.quantity += int(request.form['quantity'])
    product.put()

    return '', 204
Beispiel #4
0
def update_bar_code(product_id):
    product = Product.get_by_id(product_id)

    product.bar_code = str(request.form['bar_code'])

    product.put()

    return '', 204
Beispiel #5
0
def delete(product_id):
    product = Product.get_by_id(product_id)

    if not product:
        return 'Product id %s not found' % (product_id), 404

    product.key.delete()

    return '', 204
Beispiel #6
0
def compra(product_id):
    product = Product.get_by_id(product_id)

    if not product:
        return 'Product id %s not found' % (product_id), 404

    product.price = float(request.form['price'])
    product.quantity += int(request.form['quantity'])

    product.put()

    return '', 204
Beispiel #7
0
def modify(product_id):
    product = Product.get_by_id(product_id)

    if not product:
        return 'Product id %s not found' % (product_id), 404

    try:
        product.description = request.form['description']
        product.price = float(request.form['price'])
        product.quantity = int(request.form['quantity'])

        product.put()
    except:
        return 'Deu ruim merm\u00E3o', 400

    return '', 204