本文整理汇总了Python中shop.util.order.get_order_from_request函数的典型用法代码示例。如果您正苦于以下问题:Python get_order_from_request函数的具体用法?Python get_order_from_request怎么用?Python get_order_from_request使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_order_from_request函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_request_with_user_returns_last_order
def test_request_with_user_returns_last_order(self):
setattr(self.request, 'user', self.user)
order1 = Order.objects.create(user=self.user)
ret = get_order_from_request(self.request)
self.assertEqual(ret, order1)
order2 = Order.objects.create(user=self.user)
ret = get_order_from_request(self.request)
self.assertEqual(ret, order2)
示例2: test_04_request_with_user_returns_correct_order
def test_04_request_with_user_returns_correct_order(self):
self.create_fixtures()
setattr(self.request, 'user', self.user)
self.order.user = self.user
self.order.save()
ret = get_order_from_request(self.request)
self.assertEqual(ret, self.order)
示例3: get_context_data
def get_context_data(self, **kwargs):
ctx = super(ShopTemplateView, self).get_context_data(**kwargs)
# Set the order status:
order = get_order_from_request(self.request)
if order:
order.status = Order.COMPLETED
order.save()
else:
order = Order.objects.get_latest_for_user(self.request.user)
#TODO: Is this ever the case?
ctx.update({'order': order, })
# TODO: move away from shop!!
# ctx.update({'downloads': [1], })
completed.send(sender=self, order=order)
# Empty the customers basket, to reflect that the purchase was
# completed
cart_object = get_or_create_cart(self.request)
cart_object.empty()
return ctx
示例4: test_03_request_with_order_returns_order
def test_03_request_with_order_returns_order(self):
self.create_fixtures()
session = {}
session['order_id'] = self.order.id
setattr(self.request, 'session', session)
ret = get_order_from_request(self.request)
self.assertEqual(ret, self.order)
示例5: get_context_data
def get_context_data(self, **kwargs):
ctx = super(MyOrderConfirmView, self).get_context_data(**kwargs)
order = get_order_from_request(self.request)
ctx.update({
'order': order,
})
return ctx
示例6: entry_view
def entry_view(request, *args, **kwargs):
"""Call card's provider API with correct price and payment description."""
order = get_order_from_request(request)
amount = order.get_total()
return HttpResponseRedirect(
'https://visa.com/payment',
data={'key': 'my_secret_key',
'amount': amount})
示例7: get_context_data
def get_context_data(self, **kwargs):
ctx = super(ShopTemplateView, self).get_context_data(**kwargs)
# put the latest order in the context only if it is completed
order = get_order_from_request(self.request)
if order and order.status == Order.COMPLETED:
ctx.update({'order': order, })
return ctx
示例8: test_addresses_are_conserved_properly
def test_addresses_are_conserved_properly(self):
session = {}
session['order_id'] = self.order.id
setattr(self.request, 'session', session)
ret = get_order_from_request(self.request)
self.assertEqual(ret, self.order)
self.assertEqual(ret.shipping_address_text,
self.order.shipping_address_text)
self.assertEqual(ret.billing_address_text,
self.order.billing_address_text)
示例9: get_context_data
def get_context_data(self, **kwargs):
ctx = super(ShopTemplateView, self).get_context_data(**kwargs)
# Set the order status:
order = get_order_from_request(self.request)
order.status = Order.COMPLETED
order.save()
completed.send(sender=self, order=order)
return ctx
示例10: get_order
def get_order(self, request):
'''
Returns the order object for the current shopper.
This is called from the backend's views as:
>>> order = self.shop.getOrder(request)
'''
# it might seem a bit strange to simply forward the call to a helper,
# but this avoids exposing the shop's internal workings to module
# writers
return get_order_from_request(request)
示例11: get_context_data
def get_context_data(self, **kwargs):
ctx = super(ShopTemplateView, self).get_context_data(**kwargs)
# put the latest order in the context only if it is completed
order = get_order_from_request(self.request)
if order and order.status == Order.COMPLETED:
ctx.update({'order': order, })
# Empty the customers basket, to reflect that the purchase was
# completed
cart_object = get_or_create_cart(self.request)
cart_object.empty()
return ctx
示例12: get_context_data
def get_context_data(self, **kwargs):
ctx = super(ShopTemplateView, self).get_context_data(**kwargs)
# Set the order status:
order = get_order_from_request(self.request)
order.status = Order.COMPLETED
order.save()
completed.send(sender=self, order=order)
# Empty the customers basket, to reflect that the purchase was completed
cart_object = get_or_create_cart(self.request)
cart_object.empty()
return ctx
示例13: callback_view
def callback_view(request, *args, **kwargs):
"""Receive callback from credit card payment service and complete the order."""
order = get_order_from_request(request)
OrderPayment.objects.create(
order=order,
amount=request.POST["amount"],
transaction_id=request.POST["id"],
payment_method=PaymentBackend.objects.get(url_name="credit_card"))
order.mark_as_completed()
clean_cart(request)
return HttpResponseRedirect(reverse("home"))
示例14: pay_on_delivery
def pay_on_delivery(request):
"""
This simple PaymentBackend has only one view - entry point which does some work
internally and then redirects to the "successful URL".
More complicated views should have entry point (where it calls external API)
and a callback view which will be called by the API with result.
"""
# Get the order object
order = get_order_from_request(request)
# Since we don't know if the money will be really collected mark the order
# just as CONFIRMED instead of COMPLETED.
order.mark_as_confirmed()
clean_cart(request)
return HttpResponseRedirect(reverse("home"))
示例15: test_request_with_session_without_order_returns_none
def test_request_with_session_without_order_returns_none(self):
setattr(self.request, "session", {})
ret = get_order_from_request(self.request)
self.assertEqual(ret, None)