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


Python Order.user_id方法代码示例

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


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

示例1: order

# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import user_id [as 别名]
def order():
    if 'username' not in session:
        return redirect(url_for('login'))

    form = forms.OrderForm(formdata=request.form)
    form.category.choices = [(c.id, c.name) for c in Category.query.filter_by(subject_id=form.subject.data)]

    if ('0', 'Select...') not in form.subject.choices:
        form.subject.choices.insert(0, ('0', 'Select...'))

    if request.method == 'POST' and form.validate():

        new_order = Order()

        new_order.title = form.title.data
        new_order.user_id = session['user_id']
        new_order.subject_id = form.subject.data
        new_order.category_id = form.category.data
        new_order.os_id = form.os.data
        new_order.details = form.details.data
        new_order.deadline = form.deadline.data
        new_order.explanations = form.explanations.data

        db.session.add(new_order)
        db.session.commit()

        files = request.files.getlist('file[]')
        order_files = []
        for f in files:
            if f.filename:
                ext = f.filename.split('.')[-1]
                name = str(uuid.uuid4()) + '.' + ext
                path = os.path.join(app.config['FILE_UPLOAD_PATH'], name)
                f.save(path)

                of = File()
                of.order_id = new_order.id
                of.name = f.filename
                of.local_name = name
                order_files.append(of)

        for of in order_files:
            db.session.add(of)

        db.session.commit()

        flash('Order submitted :)', _CATEGORY_MESSAGE)

        return redirect(url_for('profile'))

    return render_template('order.html', form=form)
开发者ID:igor-osipenko,项目名称:fdi,代码行数:53,代码来源:application.py

示例2: orders_put

# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import user_id [as 别名]
def orders_put(request):
    dbsession = DBSession()
    order = Order()
    order.entity_id = clean_param_value(request, 'entity_id')
    order.user_id = clean_param_value(request, 'user_id')
    order.quantity = clean_param_value(request, 'quantity')
    order.minPrice = clean_param_value(request, 'minPrice')
    order.maxPrice = clean_param_value(request, 'maxPrice')
    order.buyOrSell = clean_param_value(request, 'buyOrSell')
    order.active = 1
    order.timestamp = get_timestamp()
    hash = hashlib.md5(order.entity_id + order.user_id + str(order.timestamp)).hexdigest()
    order.hash = hash
    dbsession.add(order)
    transaction.commit()
    order = dbsession.query(Order).filter(Order.hash == hash).one()
    order_json = convert.decodeOrder(request, dbsession, order)
    return {'status': 'success', 'order': order_json}
开发者ID:vishakh,项目名称:metamkt,代码行数:20,代码来源:views.py

示例3: add_to_cart

# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import user_id [as 别名]
def add_to_cart(request):

	if request.method=="POST" and request.POST["quantity"].isnumeric():
		o=OrderProduct()

		pid=request.POST["productid"] 
		p=Product.objects.get(pk=pid) #look through database. get object back by id. 
		o.product=p                   #need to return object as o.product expects

		# order=Order.objects.get(pk=1)
		order=Order()
		order.status=1
		order.user_id=request.user.id
		order.save()

		o.order=order

		o.quantity=request.POST["quantity"] #pass in quantity from post form
		o.save()
		return redirect("cart")

	return redirect("product_list")
开发者ID:koheif2,项目名称:first2months,代码行数:24,代码来源:views.py

示例4: placeOrder

# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import user_id [as 别名]
def placeOrder():
    formQuantities = ProductQuantityForm(request.form)
    maker_id = request.form['maker_id']
    if not maker_id:
        flash(gettext("Maker not found."))
        return redirect(url_for("orders"))

    if formQuantities.validate_on_submit():

        new_order = Order()
        #TODO other date than now   new_order.created_dt =
        new_order.maker_id = maker_id
        new_order.user_id = g.user.id
        db.session.add(new_order)
        db.session.commit()

        #add ordered products to new order
        form_data = formQuantities.data['fields']
        for product in form_data:
            new_quantity = int(product['qty_order'])
            if new_quantity > 0:
                new_product = Product.query.filter_by(id=int(product['product_id'])).first()
                if new_product:
                    op = OrderedProducts(quantity=new_quantity)
                    op.product = new_product
                    op.order_id = new_order.id
                    new_order.products.append(op)

        db.session.commit()

        # Create order sheet xls
        xls = CreateXls()
        maker = Maker.query.filter_by(id=maker_id).first()
        maker_name = maker.name
        data = []
        for item in form_data:
            if item['qty_order'] < 1:
                continue
            product = Product.query.filter_by(id=item['product_id']).first()
            if product:
                data.append({'product_code': product.code, 'product_maker_code': product.maker_code,\
                             'product_name': product.desc_CS, 'quantity': item['qty_order']})
        order_xls = xls.order_sheet(maker_name, data)
        match = re.search(r"[^a-zA-Z](ordersheet)[^a-zA-Z]", order_xls)
        pos = match.start(1)
        filename = order_xls[pos:]

        flash(gettext('New order to maker was successfully created.'))

        return render_template('orders/ordersheet.html',
                               title=gettext("Order Sheet Management"),
                               ordersheet_file=filename,
                               maker=maker,
                               mail_sent=False)

    #if not validated return to maker select
    products = Product.query.order_by(Product.maker_id, Product.code)\
        .filter_by(maker_id=int(maker_id),
                   active_flg=True).all()
    formMaker = SelectMakerForm()
    formMaker.maker.choices = [(a.id, a.name) for a in Maker.query.all()]
    return render_template('orders/createOrder.html',
                           title=gettext("Place new order to maker"),
                           formMaker=formMaker,
                           formQuantities=formQuantities,
                           products=products)
开发者ID:HeinzHinek,项目名称:AxiStore,代码行数:68,代码来源:viewsOrder.py


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