merge search into pretty branch
[wolnelektury.git] / apps / picture / views.py
1 from picture.models import Picture
2 from django.utils.datastructures import SortedDict
3 from django.shortcuts import render_to_response, get_object_or_404
4 from django.template import RequestContext
5
6
7 def picture_list(request, filter=None, template_name='catalogue/picture_list.html'):
8     """ generates a listing of all books, optionally filtered with a test function """
9
10     pictures_by_author, orphans = Picture.picture_list()
11     books_nav = SortedDict()
12     for tag in pictures_by_author:
13         if pictures_by_author[tag]:
14             books_nav.setdefault(tag.sort_key[0], []).append(tag)
15
16             #    import pdb; pdb.set_trace()
17     return render_to_response(template_name, locals(),
18         context_instance=RequestContext(request))
19
20
21 def picture_detail(request, picture):
22     picture = get_object_or_404(Picture, slug=picture)
23
24     categories = SortedDict()
25     for tag in picture.tags:
26         categories.setdefault(tag.category, []).append(tag)
27
28     picture_themes = []
29
30     return render_to_response("catalogue/picture_detail.html", locals(),
31                               context_instance=RequestContext(request))