def buy_list(request): if request.method == 'POST': # add to cart cart = BuyCart.get(request) for item in request.buy_list: if ('item-%d' % item.id) in request.POST: cart.push_item(request, item.item, inc_quantity=1, is_new=item.is_new) item.delete() return redirect(reverse('cart:index')) date_x = datetime.now() - timedelta(30) buy_orders = BuyOrder.objects.filter(user=request.user, create_date__gt=date_x).exclude(status=BuyOrderStatus.Canceled) if request.user.is_authenticated() else None return { 'buy_list': request.buy_list, 'buy_orders': buy_orders, 'trade_list': TradeListItem.get(request), 'rent_list': RentList.get(request=request), 'pending_credits': request.user.get_profile().get_pending_credits(), 'banners': [ListPageBanner.objects.get_random()], }
def __get__(self, request, obj_type=None): if not hasattr(request, '_cached_cart'): request._cached_cart = BuyCart.get(request) return request._cached_cart