def select_order(self): inputs = self.getInput() if inputs.has_key('query'): return self.orders_list() try: price, product_id = inputs['product'].split(' ') product = Products.get(Products.id == int(product_id)) order = int(inputs['order']) if order > 0: details = OrderDetails.create( name = product.category.name +" "+product.diameter, product = product, count = 1, price = price, ratio = 0.0, order = order, ) return web.seeother(self.makeUrl('/wap/edit_price_sheet', {'id': order})) else: ordersList = Orders.select().order_by(Orders.id.desc()) self.privData['ORDERS_LIST'] = ordersList self.privData['PRICE'] = price self.privData['PRODUCT'] = product return self.display('select-order') except Exception, e: print e return self.error(msg='加入订单失败!')
def confirm_select_order(self): inputs = self.getInput() try: product = Products.get(Products.id == int(inputs['product'])) user =Users.get(Users.name == self.isLogin()) price = inputs['price'] if inputs.has_key('add'): order = Orders.create( owner = user, price = price, description = product.category.name, ) else: if not inputs.has_key('selected'): return self.orders_list() order = Orders.get(Orders.id == int(inputs['selected'])) details = OrderDetails.create( name = product.category.name + " "+product.diameter, product = product, count = user, price = price, ratio = 0.0, order = order, ) return web.seeother(self.makeUrl('/wap/edit_price_sheet', {'id': order.id})) except Exception, e: print 'exc',e return self.error(msg='保存订单失败!')