本文整理匯總了Python中models.order.Order.buyer_ship_postalcode方法的典型用法代碼示例。如果您正苦於以下問題:Python Order.buyer_ship_postalcode方法的具體用法?Python Order.buyer_ship_postalcode怎麽用?Python Order.buyer_ship_postalcode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類models.order.Order
的用法示例。
在下文中一共展示了Order.buyer_ship_postalcode方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: cart_finalize
# 需要導入模塊: from models.order import Order [as 別名]
# 或者: from models.order.Order import buyer_ship_postalcode [as 別名]
def cart_finalize(seller):
T = {'sellername':seller}
helpers.template.get_user(T=T, path=request.path)
if not "user" in T:
flash(u'ログインしてから再度カートに追加してください', category='warning')
return redirect(url_for('cart_index', seller=seller))
# FIXME: ブラウザ2重起動によるセッション情報の変更検知
cart_cache_key = 'C-%s' % (T["user"].user_id())
cart = memcache.get(cart_cache_key)
if not cart or not seller in cart:
flash(u'カートが空です', category='warning')
return redirect(url_for('cart_index', seller=seller))
has_error = None
reserved = {}
for code, item in cart[seller].items():
stock = ProductStock.get_by_key_name("%s-%s" % (seller, code))
stock.quantity -= item['quantity']
if stock.quantity < 0:
has_error = code
break
stock.put()
reserved[code] = item['quantity']
if has_error:
for code, quatity in reserved.items():
stock = ProductStock.get_by_key_name("%s-%s" % (seller, code))
stock.quantity += quantity
stock.put()
flash(u'商品コード %s の在庫がなくなりました' % has_error,
category='warning')
return redirect(url_for('cart_index', seller=seller))
content = {"cart" : helpers.template.calc_cart(cart[seller]),
"buyer": cart["BUYER"]}
key_name = "-".join([seller,
T["user"].user_id(),
datetime.datetime.now().strftime('%Y-%m-%d-%H-%M-%S'),
str(random.randint(0,256))])
order = Order(key_name = key_name,
cart = unicode(json.dumps(helpers.template.calc_cart(cart[seller]))),
seller = seller,
status = 0)
order.buyer_mail = cart["BUYER"]["mail"]
order.buyer_note = cart["BUYER"]["note"]
order.buyer_ship_country = cart["BUYER"]["ship"]['country']
order.buyer_ship_postalcode = cart["BUYER"]["ship"]['postalcode']
order.buyer_ship_pref = cart["BUYER"]["ship"]['pref']
order.buyer_ship_city = cart["BUYER"]["ship"]['city']
order.buyer_ship_addr1 = cart["BUYER"]["ship"]['addr1']
order.buyer_ship_addr2 = cart["BUYER"]["ship"]['addr2']
order.put()
del(cart[seller])
memcache.set(cart_cache_key, cart, 86400)
return redirect(url_for('cart_finished', seller=seller))