Coverage for /home/chris/workspace/django-shop/shop/templatetags/shop_tags: 93.33%

# Coverage for /home/chris/workspace/django-shop/shop/templatetags/shop_tags : 93.33%

## 28 statements 26 run 2 missing 0 excluded 0 partial

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | # -*- coding: utf-8 -*- from django import template from classytags.helpers import InclusionTag from classytags.core import Options from classytags.arguments import Argument from shop.util.cart import get_or_create_cart from shop.models.productmodel import Product register = template.Library() class Cart(InclusionTag): """ Inclusion tag for displaying cart summary. """ template = 'shop/templatetags/_cart.html' def get_context(self, context): cart = get_or_create_cart(context['request']) return { 'cart': cart } register.tag(Cart) class Order(InclusionTag): """ Inclusion tag for displaying order. """ template = 'shop/templatetags/_order.html' options = Options( Argument('order', resolve=True), ) def get_context(self, context, order): return { 'order': order } register.tag(Order) class Products(InclusionTag): """ Inclusion tag for displaying all products. """ template = 'shop/templatetags/_products.html' options = Options( Argument('objects', resolve=True, required=False), ) def get_context(self, context, objects): if objects is None: objects = Product.objects.filter(active=True) context.update({'products': objects, }) return context register.tag(Products)