Skip to content

Commit

Permalink
made the default checkout view create an order object from the cart a…
Browse files Browse the repository at this point in the history
…nd attach it to the request
  • Loading branch information
Chris Glass committed Feb 15, 2011
1 parent 8aba93f commit 952ac85
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion shop/views/checkout.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,26 @@
from shop.models.ordermodel import Order
from shop.util.cart import get_or_create_cart
from shop.views import ShopTemplateView
from shop.util.order import add_order_to_request

class SelectShippingView(ShopTemplateView):
template_name = 'shop/checkout/choose_shipping.html'

def create_order_object_from_cart(self):
'''
This will create an Order object form the current cart, and will pass
a reference to the Order on either the User object or the session.
'''
cart = get_or_create_cart(self.request)
Order.objects.create_from_cart(cart)
order = Order.objects.create_from_cart(cart)
request = self.request
add_order_to_request(request, order)

def get_context_data(self, **kwargs):
'''
This overrides the context from the normal template view, and triggers
the transformation of a Cart into an Order.
'''
ctx = super(SelectShippingView, self).get_context_data(**kwargs)
shipping_modules_list = backends_pool.get_shipping_backends_list()

Expand All @@ -29,3 +40,6 @@ def get_context_data(self, **kwargs):
ctx.update({'shipping_options':select})
return ctx


class SelectPaymentView(ShopTemplateView):
pass

0 comments on commit 952ac85

Please sign in to comment.