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


Python models.Order类代码示例

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


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

示例1: truck_page

def truck_page(truck):
    items = session.query(Item).filter(Item.operator_id == truck)
    if request.method == "POST":
        user = User()
        user.firstName = request.form.get("firstName")
        user.lastName = request.form.get("lastName")
        user.email = request.form.get("email")
        session.add(user)
        session.commit()
        order = Order()
        order.operator_id = truck
        order.user = user
        order.status = "created"
        session.add(order)
        session.commit()
        for item_id in request.form.getlist("item"):
            orderitem = OrderItems()
            orderitem.order_id = order.id
            orderitem.item_id = item_id
            item = items.filter(Item.id == item_id).first()
            session.add(orderitem)
            session.commit()
        return render_template("checkout.html", key=stripe_keys["publishable_key"], order=order, user=user)
    else:
        items = items.all()
        items = filter(lambda x: x.count > 0, items)
        return render_template("truckPage.html", items=items)
开发者ID:hunterowens,项目名称:truckate_flask,代码行数:27,代码来源:app.py

示例2: post

  def post(self, event_id):
    """save the new order into db

    all items in the event have been confirmed by the contact person.. we need:
    - close the current event
    - create a new order
    """
    event = Event.get_by_id(event_id)
    if not event:
      self.error(404)
      return
    event.status = 'ordered'
    json = self.request.get('json')
    json = simplejson.loads(json)
    purchases = []
    for p in json['purchases']:
      purchase = Purchase.get(p['key'])
      purchase.item = Item.get(p['item'])
      purchase.status = 'collected'
      purchases.append(purchase.put())
    order = Order(contact=users.get_current_user(),
                  vendor=event.vendor,
                  purchases=purchases)
    order.put()
    event.put()
开发者ID:tchaikov,项目名称:beanfs,代码行数:25,代码来源:order.py

示例3: testPost4

 def testPost4(self):
     #create an order that already exists in our database
     order = Order(orderId=1,pickup_lat=1.0,pickup_lon=1.0,dropoff_lat=2.0,dropoff_lon=2.0)
     order.put()
     params ={'id':1,'plat':3.0,'plon':4.0,'dlat':11.0,'dlon':11.0}
     response = self.testapp.post('/order/new',params)
     self.assertEqual(333, response.status_int)
开发者ID:mingxiao,项目名称:ebay-now-trial,代码行数:7,代码来源:HandlerTest.py

示例4: test_update

    def test_update(self):
        order = Order(name="Dummy Order")
        order.save()

        for i in range(2):
            item = Item(name="Item %i" % i, sku=str(i) * 13, price=D("9.99"), order=order, status=0)
            item.save()

        tag = Tag(name="Test", content_object=order)
        tag.save()

        res = self.client.get("/inlines/1/")

        self.assertEqual(res.status_code, 200)
        order = Order.objects.get(id=1)

        self.assertEquals(2, order.item_set.count())
        self.assertEquals("Item 0", order.item_set.all()[0].name)

        data = {
            "name": u"Dummy Order",
            "item_set-TOTAL_FORMS": u"4",
            "item_set-INITIAL_FORMS": u"2",
            "item_set-MAX_NUM_FORMS": u"",
            "item_set-0-name": "Bubble Bath",
            "item_set-0-sku": "1234567890123",
            "item_set-0-price": D("9.99"),
            "item_set-0-status": 0,
            "item_set-0-order": 1,
            "item_set-0-id": 1,
            "item_set-1-name": "Bubble Bath",
            "item_set-1-sku": "1234567890123",
            "item_set-1-price": D("9.99"),
            "item_set-1-status": 0,
            "item_set-1-order": 1,
            "item_set-1-id": 2,
            "item_set-2-name": "Bubble Bath",
            "item_set-2-sku": "1234567890123",
            "item_set-2-price": D("9.99"),
            "item_set-2-status": 0,
            "item_set-2-order": 1,
            "item_set-3-DELETE": True,
            "tests-tag-content_type-object_id-TOTAL_FORMS": 3,
            "tests-tag-content_type-object_id-INITIAL_FORMS": 1,
            "tests-tag-content_type-object_id-MAX_NUM_FORMS": u"",
            "tests-tag-content_type-object_id-0-name": u"Test",
            "tests-tag-content_type-object_id-0-id": 1,
            "tests-tag-content_type-object_id-0-DELETE": True,
            "tests-tag-content_type-object_id-1-name": u"Test 2",
            "tests-tag-content_type-object_id-2-name": u"Test 3",
        }

        res = self.client.post("/inlines/1/", data, follow=True)
        self.assertEqual(res.status_code, 200)

        order = Order.objects.get(id=1)

        self.assertEquals(3, order.item_set.count())
        self.assertEquals(2, Tag.objects.count())
        self.assertEquals("Bubble Bath", order.item_set.all()[0].name)
开发者ID:MechanisM,项目名称:django-extra-views,代码行数:60,代码来源:tests.py

示例5: user_page

def user_page(request):
	''' This will return the page with the generated email and manage user '''
	
	email = request.REQUEST['email']

	m = hashlib.md5()

	
	# create a new order and put the requester's email in it
	new_order = Order(user_email = email)
	generated_id = str(new_order.id)

	m.update(generated_id)

	generated_email = m.hexdigest() + "@jimini.co"
	jimini_order_link = 'jimini.co/orders/' + m.hexdigest()

	# update database entry with the generated email and order link
	new_order.generated_email = generated_email
	new_order.jimini_order_link = jimini_order_link
	new_order.save()   ## TODO WEBSITE NOT TALKING

	print generated_email
	print jimini_order_link
	
	return render_to_response('user_page.html', {'generated_email' : generated_email})
开发者ID:mtbottle,项目名称:jimini,代码行数:26,代码来源:views.py

示例6: sec_tops

def sec_tops(secs):
    lt = {}
    bb = {}
    ba = {}
    for sec in secs:
        # Last traded price
        t = Trade.query(Trade.security == sec).order(-Trade.timestamp)
        t = list(t)
        if len(t) > 0:
            lt[sec.key.id()] = t[0].price
        else:
            lt[sec.key.id()] = 0
        
        # Best bid
        t = Order.query(Order.security == sec, Order.buysell == 'Buy', Order.active == True).order(-Order.price)
        t = list(t)
        if len(t) > 0:
            bb[sec.key.id()] = t[0].price
        else:
            bb[sec.key.id()] = 0
        
        # Best ask
        t = Order.query(Order.security == sec, Order.buysell == 'Sell', Order.active == True).order(Order.price)
        t = list(t)
        if len(t) > 0:
            ba[sec.key.id()] = t[0].price
        else:
            ba[sec.key.id()] = 0
    
    tops = {'lt':lt, 'bb':bb, 'ba':ba}
    return tops
开发者ID:tonyin,项目名称:chifx,代码行数:31,代码来源:scripts.py

示例7: checkout

def checkout(request):
	quantityChanged = False
	userProfile = UserProfile.objects.get(user=request.user)
	if not request.session.get(settings.CART_KEY):
		return redirect('/cart')
	cart = request.session[settings.CART_KEY]
	if not cart:
		request.flash['message'] = 'No items in cart to checkout with.'
		return redirect('/cart', context_instance=RequestContext(request))
	lineItems = line_items_from_cart(request)
	for li in lineItems:
		li.item = Item.objects.get(pk=li.item_id)
		if li.item.onHand < li.quantity:
			quantityChanged = True
			li.quantity = li.item.onHand
			request.flash[li.item.name] = 'Quantity on hand for %s is less than ordered, order changed to the number on hand.' % li.item.name
	if quantityChanged:
		request = update_cart_with_list_line_item(request, lineItems)
		return redirect('/cart', context_instance=RequestContext(request))
	order = Order(userProfile=userProfile)
	order.save()
	for li in lineItems:
		li_save = LineItem(order=order,item=li.item, quantity=li.quantity)
		li_save.save()
		update_item = Item.objects.get(pk=li.item.id)
		update_item.onHand -= li.quantity
		update_item.save()
	request.session[settings.CART_KEY] = None
	return render_to_response('checkout.html', {'order': order}, context_instance=RequestContext(request))
开发者ID:donkeystalk,项目名称:card,代码行数:29,代码来源:views.py

示例8: test_update

    def test_update(self):
        order = Order(name='Dummy Order')
        order.save()

        for i in range(2):
            item = Item(name='Item %i' % i, sku=str(i) * 13, price=D('9.99'), order=order, status=0)
            item.save()

        tag = Tag(name='Test', content_object=order)
        tag.save()

        res = self.client.get('/inlines/1/')

        self.assertEqual(res.status_code, 200)
        order = Order.objects.get(id=1)

        self.assertEquals(2, order.item_set.count())
        self.assertEquals('Item 0', order.item_set.all()[0].name)

        data = {
            'name': u'Dummy Order',
            'item_set-TOTAL_FORMS': u'4',
            'item_set-INITIAL_FORMS': u'2',
            'item_set-MAX_NUM_FORMS': u'',
            'item_set-0-name': 'Bubble Bath',
            'item_set-0-sku': '1234567890123',
            'item_set-0-price': D('9.99'),
            'item_set-0-status': 0,
            'item_set-0-order': 1,
            'item_set-0-id': 1,
            'item_set-1-name': 'Bubble Bath',
            'item_set-1-sku': '1234567890123',
            'item_set-1-price': D('9.99'),
            'item_set-1-status': 0,
            'item_set-1-order': 1,
            'item_set-1-id': 2,
            'item_set-2-name': 'Bubble Bath',
            'item_set-2-sku': '1234567890123',
            'item_set-2-price': D('9.99'),
            'item_set-2-status': 0,
            'item_set-2-order': 1,
            'item_set-3-DELETE': True,
            'tests-tag-content_type-object_id-TOTAL_FORMS': 3,
            'tests-tag-content_type-object_id-INITIAL_FORMS': 1,
            'tests-tag-content_type-object_id-MAX_NUM_FORMS': u'',
            'tests-tag-content_type-object_id-0-name': u'Test',
            'tests-tag-content_type-object_id-0-id': 1,
            'tests-tag-content_type-object_id-0-DELETE': True,
            'tests-tag-content_type-object_id-1-name': u'Test 2',
            'tests-tag-content_type-object_id-2-name': u'Test 3',
        }

        res = self.client.post('/inlines/1/', data, follow=True)
        self.assertEqual(res.status_code, 200)

        order = Order.objects.get(id=1)

        self.assertEquals(3, order.item_set.count())
        self.assertEquals(2, Tag.objects.count())
        self.assertEquals('Bubble Bath', order.item_set.all()[0].name)
开发者ID:joshdrake,项目名称:django-extra-views,代码行数:60,代码来源:tests.py

示例9: post

 def post(self, **kwargs):
     current_user = self.auth_current_user
     products = self.get_cart_content()
     items = []
     
     if self.form.validate():
         user = current_user
         delivery_method = self.form.delivery_method.data
         delivery_area = self.form.delivery_area.data
         delivery_info = self.form.delivery_info.data
         delivery_address = self.form.delivery_address.data
         delivery_city = self.form.delivery_city.data
         delivery_zip = self.form.delivery_zip.data
         comment = self.form.comment.data
         items = str(products)
         order = Order(items=items, user=user.key(), delivery_method=delivery_method, delivery_address=delivery_address, delivery_city=delivery_city, delivery_zip=delivery_zip, comment=comment, delivery_info=delivery_info, delivery_area=delivery_area)
         
         if order.put():
             url = '/mail/notify/order/'
             order_id = str(order.key().id())
             payload = { 'order_id': order_id }
             task = taskqueue.add(url=url, params=payload)
             return redirect('shop/thankyou')
         
         
     return self.get(**kwargs)
开发者ID:tresacton,项目名称:gae-shop,代码行数:26,代码来源:handlers.py

示例10: post

 def post(self):
     try:
         id = int(self.request.get("id"))
         plat = float(self.request.get("plat"))
         plon = float(self.request.get("plon"))
         dlat = float(self.request.get("dlat"))
         dlon = float(self.request.get("dlon"))
         #check if order already exists
         pastOrder = db.GqlQuery("SELECT * FROM Order WHERE orderId = :1",id).get()
         if pastOrder is None:
             order = Order(orderId =id,pickup_lat=plat,pickup_lon=plon,dropoff_lat=dlat,dropoff_lon=dlon)
             order.put()
             assign.assignDelivery()
             self.redirect('/order/needPickup')
         else:
             self.response.set_status(333,"Order already exists")
             self.response.headers['Content-Type'] = 'text/html'
             template = jinja_env.get_template('newOrder.html')
             d = {'error':'Order {} already exists'.format(id)}
             self.response.out.write(template.render())
     except ValueError:
         self.response.set_status(344,'Invalid values')
         self.response.headers['Content-Type'] = 'text/html'
         template = jinja_env.get_template('newOrder.html')
         d = {'error':'Invalid input parameters'}
         self.response.out.write(template.render(d))
开发者ID:mingxiao,项目名称:ebay-now-trial,代码行数:26,代码来源:orderHandler.py

示例11: buy

def buy(request, **kw):
    ret_str = u""
    if kw['order'] is None or kw['openId'] is None:
        mOrder = request.GET.get(u'order', None)
        mOpenId = request.GET.get(u'openId', None)
    else:
        mOrder = kw['order']
        mOpenId = kw['openId']
    print mOpenId, " ", mOrder
    if (mOrder == '' or mOrder is None or mOpenId == '' or mOpenId is None):
        result = JsonUtil.obj2json(Result('error', '非法订单'))
        return HttpResponse(result, mimetype="text/html")
    mTotal = getTotal(mOrder)
    if mTotal == -1:
        result = Result('error', '非法订单!请重新购买.')
        ret_str += unicode(result.getData(), 'utf-8')
    else:
        o = Order(openId=mOpenId, order_list=mOrder, total=mTotal)
        o.save()
        result = Result('success', '点餐成功')
        now = datetime.datetime.now().strftime('%Y-%m-%d %H:%M')
        ret_str += unicode(result.getData(), 'utf-8') + u',购买时间:' + now + u'  谢谢您的惠顾:-)'
    if request is None:
        return ret_str
    else:
        return HttpResponse(result, mimetype="text/html")
开发者ID:dreammis,项目名称:wechat_dinner,代码行数:26,代码来源:views.py

示例12: prepare_payment

def prepare_payment(request):
    if request.method == 'POST':
        form = OrderForm(request.POST)
        if form.is_valid():
            product = Clothes.objects.get(id=request.POST['product_id'])
            order = Order(
                buyer_id = request.user.id,
                address = form.cleaned_data['address'],
                phone = form.cleaned_data['phone'],
                email = request.user.email,
                amount = product.price,
                create_date = datetime.now(),
                payment_system = '11'
            )
            order.save()
            order.products.add(product)
            order.save()
            return HttpResponse(prepare_order('11', order.id, order.amount, order.phone, order.email))         
    else:
        raise Http404

    variables = RequestContext(request, {
        'form': form,
        'product': Clothes.objects.get(id=request.POST['product_id']),
    })
    return render_to_response(
        'prepare_order.html',
        variables
    )
开发者ID:BaksVenture,项目名称:suitup,代码行数:29,代码来源:views.py

示例13: checkout

def checkout(request, step=0):
    if (request.method == 'POST'):
        if request.user.is_authenticated():
            now = datetime.datetime.utcnow().replace(tzinfo=utc)
            current_user = request.user
            current_order = Order(date_time=now, user=current_user)
            current_order.save()
            for i in range(1, 6):
                print(request.POST)
                try:
                    item_quantity = int(
                        request.POST['item_quantity_' + str(i)])
                except:
                    item_quantity = None
                if not item_quantity is None:
                    item_id = request.POST['item_options_' +
                                           str(i)].split(' ')[1]
                    print(item_id)
                    current_sticker = Sticker.objects.get(pk=int(item_id))
                    print(current_sticker)
                    order_item = OrderItem(
                        order=current_order,
                        sticker=current_sticker,
                        quantity=item_quantity)
                    order_item.save()
    return redirect('/order/' + str(current_order.id) + '/1')
开发者ID:k-dev,项目名称:stickit,代码行数:26,代码来源:views.py

示例14: api_create_order

def api_create_order(request, *, customer, phone, province, city=' ', area=' ',address, payment, notes, price):

    # check_admin(request)

    if not price or not price.strip() or rubbish_filter(price):
        raise APIValueError('产品', '请选择产品')

    if not customer or not customer.strip() or rubbish_filter(customer):
        raise APIValueError("姓名","请填写姓名")

    if not phone or not phone.strip() or not phone_filter(phone):
        raise APIValueError("电话","请填写正确的手机号码")

    if not province or not city  or not address or not province.strip() or not city.strip()  or not address.strip() or rubbish_filter(province) or rubbish_filter(city) or area_filter(area) or rubbish_filter(address):
        raise APIValueError('地址', '请填写完整地址')
    address = province+city+area.strip()+address
    if not payment or not payment.strip() or rubbish_filter(payment):
        raise APIValueError("付款方式","请选择付款方式")
    if payment == '支付宝付款':
        raise APIValueError("付款方式","请选择货到付款,支付宝付款通道尚未开通")
    if rubbish_filter(notes):
        raise APIValueError("订单备注","请预留有效的备注信息")
    order = Order(customer=customer.strip(), price=price.strip(),phone=phone.strip(), address=address.strip(), payment=payment.strip(), notes=notes.strip())
    yield from order.save()
    return order
开发者ID:lokiiart,项目名称:51upali,代码行数:25,代码来源:handlers.py

示例15: testOrder

 def testOrder(self):
     order = Order(orderId=1,pickup_lat=1.0,pickup_lon=1.0,dropoff_lat=2.0,dropoff_lon=2.0)
     order.put()
     order = db.GqlQuery("SELECT * FROM Order WHERE orderId = :1 AND state = :2",1,'enRoute').get()
     self.assertEqual(None, order)
     
     order = db.GqlQuery("SELECT * FROM Order WHERE orderId = :1 AND state = :2",1,'needPickup').get()
     self.assertNotEqual(None, order)
开发者ID:mingxiao,项目名称:ebay-now-trial,代码行数:8,代码来源:HandlerTest.py


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