Skip to content

Commit

Permalink
Merge 094114c into 6f71699
Browse files Browse the repository at this point in the history
  • Loading branch information
xzzy authored Feb 20, 2019
2 parents 6f71699 + 094114c commit ec56e45
Show file tree
Hide file tree
Showing 305 changed files with 52,531 additions and 1,419 deletions.
16 changes: 15 additions & 1 deletion ledger/checkout/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from ledger.catalogue.models import Product
from ledger.basket.models import Basket
from ledger.basket.middleware import BasketMiddleware
from django.core.signing import BadSignature, Signer

Selector = get_class('partner.strategy', 'Selector')
selector = Selector()
Expand Down Expand Up @@ -50,6 +51,20 @@ def create_basket_session(request, parameters):
return basket, BasketMiddleware().get_basket_hash(basket.id)


def get_cookie_basket(cookie_key,request):
basket = None
if cookie_key in request.COOKIES:
basket_hash = request.COOKIES[cookie_key]
try:
basket_id = Signer(sep='|').unsign(basket_hash)
basket = Basket.objects.get(pk=basket_id,
status=Basket.OPEN)
except (BadSignature, Basket.DoesNotExist):
request.cookies_to_delete.append(cookie_key)
return basket
return None


# create a checkout session in Oscar.
# the checkout session contains all of the attributes about a purchase session (e.g. payment method,
# shipping method, ID of the person performing the checkout)
Expand Down Expand Up @@ -99,7 +114,6 @@ def place_order_submission(request):
from ledger.checkout.views import PaymentDetailsView
pdv = PaymentDetailsView(request=request, checkout_session=CheckoutSessionData(request))
result = pdv.handle_place_order_submission(request)

return result


Expand Down
Loading

0 comments on commit ec56e45

Please sign in to comment.