当前位置: 首页>>代码示例>>Python>>正文


Python Product.price方法代码示例

本文整理汇总了Python中product.Product.price方法的典型用法代码示例。如果您正苦于以下问题:Python Product.price方法的具体用法?Python Product.price怎么用?Python Product.price使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在product.Product的用法示例。


在下文中一共展示了Product.price方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: manage_beverages_add

# 需要导入模块: from product import Product [as 别名]
# 或者: from product.Product import price [as 别名]
def manage_beverages_add():
    if request.method == 'POST':
        p = Product()
        error = None
        logging.info(request)
        p.name = request.form['name']
        #if request.form['price'].isnumeric():
        p.price = float(request.form['price'])
        #else:
        #    error = "Preis muss eine Nummer sein."

        if 'isshown' in request.form:
            p.isshown = True
        else:
            p.isshown = False

        pic = request.files['file']
        logging.info(pic.filename)
        if pic:
            extension = pic.filename.rsplit('.', 1)[1].lower()
            logging.info(extension)
            if extension == "png" or extension == "jpg":
                pic.seek(0) # Move cursor back to beginning so we can write to disk
                fpath = os.path.join("./app/static/", "product_%s.png" % p.name)
                pic.save(fpath)

        if error is None:
            add_product(p)
            return render_template('manage_beverages_add.html', success="Konsumat hinzugefuegt.", user=get_user_by_name(session.get('name')))

        return render_template('manage_beverages_add.html', error=error, user=get_user_by_name(session.get('name')))
    return render_template('manage_beverages_add.html', user=get_user_by_name(session.get('name')))
开发者ID:ulrichknecht,项目名称:baroness,代码行数:34,代码来源:views.py

示例2: manage_beverages_edit

# 需要导入模块: from product import Product [as 别名]
# 或者: from product.Product import price [as 别名]
def manage_beverages_edit(name=None):
    if request.method == 'GET':
        error = None
        p = get_product_by_name(name)

        if p is None:
            error = "Product existiert nicht"

        return render_template('manage_beverages_edit.html', product_to_edit=p, error=error, user=get_user_by_name(session.get('name')))

    if request.method == 'POST':
        p = Product()
        #print request.form
        p.id = request.form['id']
        p.name = request.form['name']
        p.price = float(request.form['price'])

        if 'isshown' in request.form:
            p.isshown = True
        else:
            p.isshown = False

        pic = request.files['file']
        if pic:
            extension = pic.filename.rsplit('.', 1)[1].lower()
            if extension == "png" or extension == "jpg":
                pic.seek(0) # Move cursor back to beginning so we can write to disk
                fpath = os.path.join("./app/static/", "product_%s.png" % p.name)
                pic.save(fpath)

        update_product(p)

        # update_user(u)

        return redirect('/manage_beverages')
开发者ID:ulrichknecht,项目名称:baroness,代码行数:37,代码来源:views.py

示例3: get_product_by_name

# 需要导入模块: from product import Product [as 别名]
# 或者: from product.Product import price [as 别名]
def get_product_by_name(name):
    row = query_db("SELECT * FROM PRODUCTS WHERE NAME = ?", [str(name)], one=True)
    p = Product()
    p.id = row[0]
    p.name = row[1]
    p.price = row[2]
    p.isshown = row[3]
    return p
开发者ID:ulrichknecht,项目名称:baroness,代码行数:10,代码来源:database.py

示例4: get_product_by_id

# 需要导入模块: from product import Product [as 别名]
# 或者: from product.Product import price [as 别名]
def get_product_by_id(id):
    row = query_db("SELECT * FROM PRODUCTS WHERE ID = ?", [str(id)], one=True)
#    print row
    p = Product()
    p.id = row[0]
    p.name = row[1]
    p.price = row[2]
    p.isshown = row[3]
    return p
开发者ID:ulrichknecht,项目名称:baroness,代码行数:11,代码来源:database.py

示例5: get_products

# 需要导入模块: from product import Product [as 别名]
# 或者: from product.Product import price [as 别名]
def get_products():
    rows = query_db("SELECT * FROM PRODUCTS")
    products = []
    for row in rows:
        p = Product()
        p.id = row[0]
        p.name = row[1]
        p.price = row[2]
        p.isshown = row[3]
        products.append(p)
    return products
开发者ID:ulrichknecht,项目名称:baroness,代码行数:13,代码来源:database.py


注:本文中的product.Product.price方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。