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