Coverage for /home/tribaal/workspace/django-shop/shop/templatetags/shop_tags: 77.50%

# Coverage for /home/tribaal/workspace/django-shop/shop/templatetags/shop_tags : 77.50%

## 36 statements 29 run 7 missing 0 excluded 0 partial

Hot-keys on this page

r m x p toggle line displays

j k next/prev highlighted chunk

0 (zero) top of page

1 (one) first highlighted chunk

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 60 61 62 63 64 65 66 67 68 69 | # -*- 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 from django.conf import settings 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']) cart.update() 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) def priceformat(price): FORMAT = getattr(settings, 'SHOP_PRICE_FORMAT', '%0.2f') if not price and price != 0: return '' return FORMAT % price register.filter(priceformat)