コード例 #1
0
ファイル: context_processors.py プロジェクト: H359/BarboskeRu
def common_pieces(request):
    categories = Category.get_tree()
    if request.is_ajax():
	template = 'base_ajax.html'
    else:
	template = 'base.html'
    return {
	'base_template': template,
	'shop': {
            'basket': Basket(request),
	    'categories': categories
	}
    }
コード例 #2
0
ファイル: views.py プロジェクト: H359/BarboskeRu
def category(request, path=None):
    tree = Category.get_tree()
    res = {}
    if path is None:
        res['root'] = tree[0]
    else:
        if path.endswith('.html'):
            ware_slug = path.split('/')[-1][:-5]
            path = path[0:len(path)-len(ware_slug)-6]
            res['ware'] = Ware.objects.get(slug=ware_slug)
            res['TEMPLATE'] = 'shop/ware.html'
        candidates = [x for x in tree if x._materialized_path == path]
        if len(candidates) <> 1:
            raise Http404
        res['root'] = candidates[0]
    return res