X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/b3ea0bf90c381d31936f81c96dffd25ca30a1664..e18d543fa8e2bd224880a79fb71ea8726b1d45bf:/apps/catalogue/views.py?ds=sidebyside 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:])