-def catalogue(request, as_json=False):
- common_categories = ('author',)
- split_categories = ('epoch', 'genre', 'kind')
-
- categories = split_tags(
- get_top_level_related_tags(categories=common_categories),
- models.Tag.objects.usage_for_model(
- models.Fragment, counts=True).filter(category='theme'),
- models.Tag.objects.usage_for_model(
- Picture, counts=True).filter(category__in=common_categories),
- models.Tag.objects.usage_for_model(
- PictureArea, counts=True).filter(
- category='theme')
- )
- book_categories = split_tags(
- get_top_level_related_tags(categories=split_categories)
- )
- picture_categories = split_tags(
- models.Tag.objects.usage_for_model(
- Picture, counts=True).filter(
- category__in=split_categories),
- )
-
- collections = models.Collection.objects.all()
-
- def render_tag_list(tags):
- return render_to_string('catalogue/tag_list.html', tag_list(tags))
-
- def render_split(with_books, with_pictures):
- ctx = {}
- if with_books:
- ctx['books'] = render_tag_list(with_books)
- if with_pictures:
- ctx['pictures'] = render_tag_list(with_pictures)
- return render_to_string('catalogue/tag_list_split.html', ctx)
-
- output = {}
- output['theme'] = render_tag_list(categories.get('theme', []))
- for category in common_categories:
- output[category] = render_tag_list(categories.get(category, []))
- for category in split_categories:
- output[category] = render_split(
- book_categories.get(category, []),
- picture_categories.get(category, []))
-
- output['collections'] = render_to_string(
- 'catalogue/collection_list.html', collection_list(collections))
- if as_json:
- return JsonResponse(output)
- else:
- return render_to_response('catalogue/catalogue.html', locals(),
- context_instance=RequestContext(request))
-
-
-@ssi_included
-def catalogue_json(request):
- return catalogue(request, True)
+def catalogue(request):
+ return render(request, 'catalogue/catalogue.html', {
+ 'books': Book.objects.filter(parent=None).order_by('sort_key_author', 'sort_key'),
+ 'pictures': Picture.objects.order_by('sort_key_author', 'sort_key'),
+ 'collections': Collection.objects.all(),
+ 'active_menu_item': 'all_works',
+ })