2017-02-03 10:04:57 +00:00
|
|
|
from django.shortcuts import render
|
2017-03-09 08:33:44 +00:00
|
|
|
from django.views.generic import ListView
|
|
|
|
from longclaw.longclawbasket.models import BasketItem
|
|
|
|
from longclaw.longclawbasket import utils
|
2017-02-03 10:04:57 +00:00
|
|
|
|
2017-03-09 08:33:44 +00:00
|
|
|
class BasketView(ListView):
|
|
|
|
model = BasketItem
|
2017-04-06 21:49:58 +00:00
|
|
|
template_name = "longclawbasket/basket.html"
|
2017-03-09 08:33:44 +00:00
|
|
|
def get_context_data(self, **kwargs):
|
|
|
|
items, _ = utils.get_basket_items(self.request)
|
2017-04-12 14:37:55 +00:00
|
|
|
total_price = sum(item.total() for item in items)
|
|
|
|
return {"basket": items, "total_price": total_price}
|