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


Python Order.put方法代码示例

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


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

示例1: testPost4

# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import put [as 别名]
 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,代码行数:9,代码来源:HandlerTest.py

示例2: post

# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import put [as 别名]
  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,代码行数:27,代码来源:order.py

示例3: post

# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import put [as 别名]
 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,代码行数:28,代码来源:orderHandler.py

示例4: testIdleOrders

# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import put [as 别名]
 def testIdleOrders(self):
     order = Order(orderId=1,pickup_lat=1.0,pickup_lon=1.0,dropoff_lat=2.0,dropoff_lon=2.0)
     order.put()
     order = Order(orderId=2,pickup_lat=11.0,pickup_lon=1.0,dropoff_lat=2.0,dropoff_lon=2.0)
     order.put()
     
     orders = assign.idleOrders()
     self.assertEqual(2, orders.count())
开发者ID:mingxiao,项目名称:ebay-now-trial,代码行数:10,代码来源:HandlerTest.py

示例5: testOrder

# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import put [as 别名]
 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,代码行数:10,代码来源:HandlerTest.py

示例6: testPost3

# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import put [as 别名]
 def testPost3(self):
     #courier found, but order not found
     order = Order(orderId=1,pickup_lat=1.0,pickup_lon=1.0,dropoff_lat=2.0,dropoff_lon=2.0)
     order.put()
     courier = Courier(courierId=7,lat=2.0,lon=3.0)
     courier.put()
     response = self.testapp.post('/courier/7/complete')
     self.assertEqual(333,response.status_int)
开发者ID:mingxiao,项目名称:ebay-now-trial,代码行数:10,代码来源:HandlerTest.py

示例7: testPost2

# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import put [as 别名]
 def testPost2(self):
     #courier not found
     order = Order(orderId=1,pickup_lat=1.0,pickup_lon=1.0,dropoff_lat=2.0,dropoff_lon=2.0)
     order.put()
     courier = Courier(courierId=1,lat=2.0,lon=3.0,orderId=1)
     courier.put()
     self.assertEqual(1,len(Courier.all().fetch(20)))
     # if the courier is not found, nothing should be changed
     response = self.testapp.post('/courier/2/complete')
     self.assertEqual(333,response.status_int)
开发者ID:mingxiao,项目名称:ebay-now-trial,代码行数:12,代码来源:HandlerTest.py

示例8: testAvailableCourierId

# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import put [as 别名]
 def testAvailableCourierId(self):
     order = Order(orderId=1,pickup_lat=1.0,pickup_lon=1.0,dropoff_lat=2.0,dropoff_lon=2.0,state='enRoute',courierId= 3)
     order.put()
     courier = Courier(courierId=1,lat=2.0,lon=3.0,online=True)
     courier.put()
     
     courier = Courier(courierId=3,lat=4.0,lon=3.0,online=True)
     courier.put()
     courier = Courier(courierId=8,lat=4.0,lon=3.0,online=True)
     courier.put()
     self.assertEqual([1,8],assign.availableCourierId())
开发者ID:mingxiao,项目名称:ebay-now-trial,代码行数:13,代码来源:HandlerTest.py

示例9: testFormMatrix

# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import put [as 别名]
 def testFormMatrix(self):
     courier = Courier(courierId=1,lat=2.0,lon=3.0,online=True)
     courier.put()
     courier = Courier(courierId=3,lat=14.0,lon=13.0,online=True)
     courier.put()
     order = Order(orderId=4,pickup_lat=1.0,pickup_lon=1.0,dropoff_lat=2.0,dropoff_lon=2.0)
     order.put()
     order = Order(orderId=5,pickup_lat=11.0,pickup_lon=11.0,dropoff_lat=2.0,dropoff_lon=2.0)
     order.put()
     
     orders = assign.idleOrders()
     couriers = assign.availableCouriers()
     matrix  = self.mkres.form_matrix(orders, couriers)
开发者ID:mingxiao,项目名称:ebay-now-trial,代码行数:15,代码来源:HandlerTest.py

示例10: testPost1

# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import put [as 别名]
 def testPost1(self):
     #courier and order exists
     order = Order(orderId=1,pickup_lat=1.0,pickup_lon=1.0,dropoff_lat=2.0,dropoff_lon=2.0)
     order.put()
     courier = Courier(courierId=7,lat=2.0,lon=3.0,orderId=7)
     courier.put()
     response = self.testapp.post('/courier/7/accept/1')
     self.assertEqual(200, response.status_int)
     #check that courier has properly changed
     result_courier = db.GqlQuery("SELECT * FROM Courier WHERE courierId = 7").get()
     #check order has properly changed
     result_order = db.GqlQuery("SELECT * FROM Order WHERE orderId = 1").get()
     self.assertEqual('enRoute',result_order.state)
开发者ID:mingxiao,项目名称:ebay-now-trial,代码行数:15,代码来源:HandlerTest.py

示例11: testAssignDelivery2

# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import put [as 别名]
 def testAssignDelivery2(self):
     #have orders, but no couriers
     order = Order(orderId=1,pickup_lat=1.0,pickup_lon=1.0,dropoff_lat=2.0,dropoff_lon=2.0)
     order.put()
     order = Order(orderId=2,pickup_lat=11.0,pickup_lon=1.0,dropoff_lat=2.0,dropoff_lon=2.0)
     order.put()
     
     assign.assignDelivery()
     posOrder = db.GqlQuery("SELECT * FROM Order WHERE orderId = 1").get()
     self.assertEqual(None,posOrder.courierId)
     self.assertEqual('needPickup',posOrder.state)
     posOrder = db.GqlQuery("SELECT * FROM Order WHERE orderId = 2").get()
     self.assertEqual(None,posOrder.courierId)
     self.assertEqual('needPickup',posOrder.state)
开发者ID:mingxiao,项目名称:ebay-now-trial,代码行数:16,代码来源:HandlerTest.py

示例12: testInsertCourier2

# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import put [as 别名]
    def testInsertCourier2(self):
        #populate with some orders awaiting pickup 
        order = Order(orderId=1,pickup_lat=1.0,pickup_lon=1.0,dropoff_lat=2.0,dropoff_lon=2.0)
        order.put()
        order = Order(orderId=2,pickup_lat=10.0,pickup_lon=10.0,dropoff_lat=2.0,dropoff_lon=2.0)
        order.put()
        order = Order(orderId=3,pickup_lat=10.0,pickup_lon=1.0,dropoff_lat=12.0,dropoff_lon=2.0)
        order.put()
        order = Order(orderId=4,pickup_lat=1.0,pickup_lon=10.0,dropoff_lat=2.0,dropoff_lon=12.0)
        order.put()
        #create a new courier
        params = {'id': 1, 'lat': 10.0,'lon':2.0}
        response = self.testapp.post('/courier/new', params)
        self.assertEqual(302,response.status_int)
        #check courier assigned correct order
#        courier = db.GqlQuery("SELECT * FROM Courier WHERE courierId = 1").get()
#        self.assertEqual(3,courier.orderId)
#        self.assertEqual(False,courier.online)
        #check that the assigned order is enRoute
        posOrder = db.GqlQuery("SELECT * FROM Order WHERE orderId = 3").get()
        self.assertEqual(1,posOrder.courierId)
        self.assertEqual('enRoute',posOrder.state)
        #check that the other orders are still unassigned
        for id in [1,2,4]:
            negOrder = db.GqlQuery("SELECT * FROM Order WHERE orderId = :1",id).get()
            self.assertEqual(None,negOrder.courierId)
            self.assertEqual('needPickup',negOrder.state)
        #check that other couriers do not exist
        courier = db.GqlQuery("SELECT * FROM Courier WHERE courierId = 3").get()
        self.assertEqual(None, courier)
开发者ID:mingxiao,项目名称:ebay-now-trial,代码行数:32,代码来源:HandlerTest.py

示例13: testUnavailableCouriers

# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import put [as 别名]
 def testUnavailableCouriers(self):
     order = Order(orderId=1,pickup_lat=1.0,pickup_lon=1.0,dropoff_lat=2.0,dropoff_lon=2.0,state='enRoute',courierId= 3)
     order.put()
     courier = Courier(courierId=1,lat=2.0,lon=3.0,online=True)
     courier.put()
     
     courier = Courier(courierId=3,lat=4.0,lon=3.0,online=True)
     courier.put()
     
     courier = Courier(courierId=4,lat=4.0,lon=3.0,online=True)
     courier.put()
     
     couriers = assign.unavailableCouriers()
     for c in couriers:
         self.assertIn(c.courierId, [3])
开发者ID:mingxiao,项目名称:ebay-now-trial,代码行数:17,代码来源:HandlerTest.py

示例14: post

# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import put [as 别名]
 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,代码行数:28,代码来源:handlers.py

示例15: testLowestCost

# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import put [as 别名]
 def testLowestCost(self):
     courier = Courier(courierId=1,lat=2.0,lon=3.0,online=True)
     courier.put()
     courier = Courier(courierId=3,lat=14.0,lon=13.0,online=True)
     courier.put()
     order = Order(orderId=4,pickup_lat=1.0,pickup_lon=1.0,dropoff_lat=2.0,dropoff_lon=2.0)
     order.put()
     order = Order(orderId=5,pickup_lat=11.0,pickup_lon=11.0,dropoff_lat=2.0,dropoff_lon=2.0)
     order.put()
     
     orders = assign.idleOrders()
     couriers = assign.availableCouriers()
     indexes = self.mkres.lowest_cost(orders, couriers)
     self.assertEqual(2,len(indexes))
     for elem in indexes:
         self.assertEqual(2,len(elem))
开发者ID:mingxiao,项目名称:ebay-now-trial,代码行数:18,代码来源:HandlerTest.py


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