Librarian: support for <abstrakt>
[wolnelektury.git] / apps / libraries / views.py
1 # -*- coding: utf-8 -*-\r
2 # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.\r
3 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.\r
4 #\r
5 from django.shortcuts import render_to_response, get_object_or_404\r
6 from django.template import RequestContext\r
7 \r
8 from libraries.models import Catalog, Library\r
9 \r
10 \r
11 def main_view(request):\r
12     context = RequestContext(request)\r
13     context['catalogs'] = Catalog.objects.all()\r
14     return render_to_response('libraries/main_view.html', context_instance=context)\r
15 \r
16 def catalog_view(request, slug):\r
17     context = RequestContext(request)\r
18     context['catalog'] = get_object_or_404(Catalog.objects.filter(slug=slug).select_related())\r
19     return render_to_response('libraries/catalog_view.html', context_instance=context)\r
20     \r
21 def library_view(request, catalog_slug, slug):\r
22     context = RequestContext(request)\r
23     context['library'] = get_object_or_404(Library.objects.filter(slug=slug).filter(catalog__slug=catalog_slug))\r
24     return render_to_response('libraries/library_view.html', context_instance=context)\r