active menu item for picture page
[wolnelektury.git] / src / 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 \r
17 def catalog_view(request, slug):\r
18     context = RequestContext(request)\r
19     context['catalog'] = get_object_or_404(Catalog.objects.filter(slug=slug).select_related())\r
20     return render_to_response('libraries/catalog_view.html', context_instance=context)\r
21 \r
22 \r
23 def library_view(request, catalog_slug, slug):\r
24     context = RequestContext(request)\r
25     context['library'] = get_object_or_404(Library.objects.filter(slug=slug).filter(catalog__slug=catalog_slug))\r
26     return render_to_response('libraries/library_view.html', context_instance=context)\r