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


Python Item.quantity方法代码示例

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


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

示例1: _create_item_in_database

# 需要导入模块: from models import Item [as 别名]
# 或者: from models.Item import quantity [as 别名]
    def _create_item_in_database(self, cart, product, quantity=1, 
            unit_price=Decimal("100")):
        """
            Helper function so I don't repeat myself
        """  
        item = Item()
        item.cart = cart
        item.product = product
        item.quantity = quantity
        item.unit_price = unit_price
        item.save() 

        return item
开发者ID:CARocha,项目名称:django-cart,代码行数:15,代码来源:tests.py

示例2: add_inventory_item_json

# 需要导入模块: from models import Item [as 别名]
# 或者: from models.Item import quantity [as 别名]
def add_inventory_item_json(data):
    name = data['name']
    description = data['description']
    quantity = int(data['quantity'])
    price = int(data['price'])

    item = Item.query.filter_by(name=name).first()
    if item is None:
        item = Item(name=name, description=description, quantity=quantity,
                    price=price)
        db.session.add(item)
    else:
        item.name = name
        item.quantity = quantity
        item.price = price
        if description != "":
            item.description = description
    db.session.commit()
    return jsonify(status="success")
开发者ID:deveshj4,项目名称:tol,代码行数:21,代码来源:inventory_helper.py

示例3: add_inventory_item_html

# 需要导入模块: from models import Item [as 别名]
# 或者: from models.Item import quantity [as 别名]
def add_inventory_item_html(form):
    name = form.name.data.strip()
    description = form.description.data.strip()
    quantity = form.quantity.data
    price = form.price.data

    item = Item.query.filter_by(name=name).first()
    if item is None:
        item = Item(name=name, description=description, quantity=quantity,
                    price=price)
        db.session.add(item)
    else:
        item.name = name
        item.quantity = quantity
        item.price = price
        if description != "":
            item.description = description
    db.session.commit()
    return True
开发者ID:deveshj4,项目名称:tol,代码行数:21,代码来源:inventory_helper.py

示例4: save

# 需要导入模块: from models import Item [as 别名]
# 或者: from models.Item import quantity [as 别名]
 def save(cls, request: Request, *args, **kwargs):
     """ Метод для сохранения товара
     :param request:
     :param kwargs:
     :return:
     """
     if request.get("id", False):
         item = catalog.get_item(int(request.get("id")))
     else:
         item = Item()
     item.title = request.get("title")
     item.article = request.get("article")
     item.short = request.get("short")
     item.imgs = request.get("imgs", [])
     item.body = request.get("body", "")
     item.tags = request.get("tags", [])
     item.categories = request.get("categories", [])
     item.cost = int(request.get("cost", 0)) if str(request.get("cost")).isnumeric() else None
     item.discount = int(request.get("discount")) if str(request.get("discount")).isnumeric() else None
     item.quantity = int(request.get("quantity")) if str(request.get("quantity")).isnumeric() else None
     item.set_attributes(request.get("attributes", []))
     return {"item_id": item.save()}
开发者ID:ayurjev,项目名称:catalog-api,代码行数:24,代码来源:controllers.py


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