from django import template from django.core.urlresolvers import Resolver404, resolve from django.utils import six from django.utils.six.moves.urllib import parse from django.utils.translation import ugettext_lazy as _ from oscar.apps.customer import history from oscar.core.compat import assignment_tag from oscar.core.loading import get_model Site = get_model('sites', 'Site') register = template.Library() assignment_tag = assignment_tag(register) @register.inclusion_tag('customer/history/recently_viewed_products.html', takes_context=True) def recently_viewed_products(context, current_product=None): """ Inclusion tag listing the most recently viewed products """ request = context['request'] products = history.get(request) if current_product: products = [p for p in products if p != current_product] return {'products': products, 'request': request} @assignment_tag(takes_context=True) # noqa (too complex (11)) def get_back_button(context):
from django import template from oscar.core.compat import assignment_tag from oscar.core.loading import get_model register = template.Library() Category = get_model('catalogue', 'category') assignment_tag = assignment_tag(register) @assignment_tag(name="category_tree") def get_annotated_list(depth=None, parent=None): """ Gets an annotated list from a tree branch. Borrows heavily from treebeard's get_annotated_list """ # 'depth' is the backwards-compatible name for the template tag, # 'max_depth' is the better variable name. max_depth = depth annotated_categories = [] start_depth, prev_depth = (None, None) if parent: categories = parent.get_descendants() if max_depth is not None: max_depth += parent.get_depth() else: categories = Category.get_tree()