Book page fix
[wolnelektury.git] / src / libraries / views.py
1 # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
2 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
3 #
4 from django.shortcuts import render, get_object_or_404
5 from libraries.models import Catalog, Library
6
7
8 def main_view(request):
9     return render(request, 'libraries/main_view.html', {
10         "catalogs": Catalog.objects.all(),
11     })
12
13
14 def catalog_view(request, slug):
15     return render(request, 'libraries/catalog_view.html', {
16         "catalog": get_object_or_404(Catalog.objects.filter(slug=slug).select_related()),
17     })
18
19 def library_view(request, catalog_slug, slug):
20     return render(request, 'libraries/library_view.html', {
21         "library": get_object_or_404(Library.objects.filter(slug=slug).filter(catalog__slug=catalog_slug)),
22     })