X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/22af332597f857ee4fe60ea2ebfd8723fd9d5da9..764fcc72600a23d5093511228dee596b55c45c72:/apps/catalogue/views.py diff --git a/apps/catalogue/views.py b/apps/catalogue/views.py index c80853437..bf0c42f70 100644 --- a/apps/catalogue/views.py +++ b/apps/catalogue/views.py @@ -70,7 +70,8 @@ def main_page(request): context_instance=RequestContext(request)) -def book_list(request, filter=None, template_name='catalogue/book_list.html'): +def book_list(request, filter=None, template_name='catalogue/book_list.html', + context=None): """ generates a listing of all books, optionally filtered with a test function """ form = forms.SearchForm() @@ -95,6 +96,17 @@ def daisy_list(request): template_name='catalogue/daisy_list.html') +def collection(request, slug): + coll = get_object_or_404(models.Collection, slug=slug) + slugs = coll.book_slugs.split() + # allow URIs + slugs = [slug.rstrip('/').rsplit('/', 1)[-1] if '/' in slug else slug + for slug in slugs] + return book_list(request, Q(slug__in=slugs), + template_name='catalogue/collection.html', + context={'collection': coll}) + + def differentiate_tags(request, tags, ambiguous_slugs): beginning = '/'.join(tag.url_chunk for tag in tags) unparsed = '/'.join(ambiguous_slugs[1:])