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