Esempio n. 1
0
def delete_product(current_user_toke, id):
    # Look for the product to delete via the id
    product = Product.query.get(id)
    db.session.delete(product)
    db.session.commit()

    return product_schema.jsonify(product)
def delete_product(id):
    # Look for a product to delete by its id
    product = Product.query.get(id)
    db.session.delete(product)
    db.session.commit()

    return product_schema.jsonify(product)
Esempio n. 3
0
def add_product(current_user_token):
    name = request.json['name']
    description = request.json['description']
    price = request.json['price']
    qty = request.json['qty']
    photo = request.json['photo']
    color_way = request.json['color_way']

    new_product = Product(name, description, price, qty, photo, color_way)

    db.session.add(new_product)
    db.session.commit()

    return product_schema.jsonify(new_product)
Esempio n. 4
0
def add_product(current_user_token):
    #when adding to the database
    name = request.json['name']
    desc = request.json['desc']
    price = request.json['price']
    qty = request.json['qty']
    photo = request.json['photo']
    color = request.json['color']

    new_product = Product(name, desc, price, qty, photo, color)
    
    db.session.add(new_product)
    db.session.commit()

    return product_schema.jsonify(new_product)
Esempio n. 5
0
def update_product(id):
    product = Product.query.get(id)

    # Say what we want to update
    name = request.json['name']
    description = request.json['description']
    price = request.json['price']
    qty = request.json['qty']
    photo = request.json['photo']
    color_way = request.json['color_way']

    product.name = name
    product.description = description
    product.price = price
    product.qty = qty
    product.photo = photo
    product.color_way = color_way

    db.session.commit()

    return product_schema.jsonify(product)
Esempio n. 6
0
def update_product(current_user_token, id):
    product = Product.query.get(id)

    name = request.json['name']
    description = request.json['description']
    price = request.json['price']
    qty = request.json['qty']
    photo = request.json['photo']
    color_way = request.json['color_way']

    # Updates to the Database From the request that came in
    product.name = name
    product.description = description
    product.price = price
    product.qty = qty
    product.photo = photo
    product.color_way = color_way

    # Commit changes to database
    db.session.commit()

    return product_schema.jsonify(product)
Esempio n. 7
0
def update_product(current_user_token):
    product = Product.quert.get(id)

    name = request.json['name']
    desc = request.json['desc']
    price = request.json['price']
    qty = request.json['qty']
    photo = request.json['photo']
    color = request.json['color']

    #updates to the database from the request that came in
    product.name = name
    prodcut.desc = desc
    product.price = price
    product.qty = qty
    product.photo = photo
    product.color = color

    #commit to db
    db.session.commit()

    return product_schema.jsonify(product)
def update_product(id):
    # Get the product that we want to update based on its id
    product = Product.query.get(id)

    # Tell endpoint what to update
    name = request.json['name']
    description = request.json['description']
    price = request.json['price']
    qty = request.json['qty']
    photo = request.json['photo']
    color_way = request.json['color_way']

    # Save the updated value to database
    product.name = name
    product.description = description
    product.price = price
    product.qty = qty
    product.photo = photo
    product.color_way = color_way

    # Commit the changes of values into Database
    db.session.commit()

    return product_schema.jsonify(product)
Esempio n. 9
0
def get_product(current_user_token, id):
    product = Product.query.get(id)
    return product_schema.jsonify(product)
def get_product(id):
    product = Product.query.get(id)
    return product_schema.jsonify(product)
Esempio n. 11
0
def get_product(current_user_token, id):  #token_required tells get_productwhat params it needs
    product = Product.query.get(id)
    return product_schema.jsonify(product)
Esempio n. 12
0
def delete_product(id):
    product = Product.query.get(id)
    db.session.delete(product)
    db.session.commit()

    return product_schema.jsonify(product)