forked from awesto/django-shop
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Turned the cart template tag into a classytag, because being classy i…
…s good ;-)
- Loading branch information
Jonas Obrist
committed
Apr 5, 2011
1 parent
42082bb
commit a943452
Showing
2 changed files
with
12 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,22 @@ | ||
# -*- coding: utf-8 -*- | ||
from django import template | ||
from classytags.helpers import InclusionTag | ||
|
||
from shop.util.cart import get_or_create_cart | ||
|
||
|
||
register = template.Library() | ||
|
||
|
||
@register.inclusion_tag('shop/templatetags/_cart.html', takes_context=True) | ||
def cart(context): | ||
class Cart(InclusionTag): | ||
''' | ||
Inclusion tag for displaying cart summary. | ||
''' | ||
cart = get_or_create_cart(context['request']) | ||
return { | ||
'cart': cart, | ||
} | ||
template = 'shop/templatetags/_cart.html' | ||
|
||
def get_context(self, context): | ||
cart = get_or_create_cart(context['request']) | ||
return { | ||
'cart': cart | ||
} | ||
register.tag(Cart) |