X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/1a6872f821959ade6a7382012338d628a4244877..01ba89e7caab3e386df4b1a99a93b98a237a0457:/apps/libraries/views.py diff --git a/apps/libraries/views.py b/apps/libraries/views.py index 45e60ddbf..7e245adbd 100644 --- a/apps/libraries/views.py +++ b/apps/libraries/views.py @@ -1,10 +1,24 @@ +# -*- coding: utf-8 -*- +# This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later. +# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. +# from django.shortcuts import render_to_response, get_object_or_404 -from django.template import RequestContext, Template, TemplateSyntaxError +from django.template import RequestContext -from libraries.models import Catalog +from libraries.models import Catalog, Library -def main_view(request, slug): +def main_view(request): context = RequestContext(request) - context['catalog'] = get_object_or_404(Catalog.objects.filter(slug = slug).select_related()) - return render_to_response('libraries/main_view.html', context_instance = context) \ No newline at end of file + context['catalogs'] = Catalog.objects.all() + return render_to_response('libraries/main_view.html', context_instance=context) + +def catalog_view(request, slug): + context = RequestContext(request) + context['catalog'] = get_object_or_404(Catalog.objects.filter(slug=slug).select_related()) + return render_to_response('libraries/catalog_view.html', context_instance=context) + +def library_view(request, catalog_slug, slug): + context = RequestContext(request) + context['library'] = get_object_or_404(Library.objects.filter(slug=slug).filter(catalog__slug=catalog_slug)) + return render_to_response('libraries/library_view.html', context_instance=context)