1 # This file is part of FNP-Redakcja, licensed under GNU Affero GPLv3 or later.
2 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
4 from django.db.models import Prefetch
5 from django.views.generic import DetailView, TemplateView
7 import documents.models
10 class CatalogueView(TemplateView):
11 template_name = "catalogue/catalogue.html"
13 def get_context_data(self):
14 ctx = super().get_context_data()
15 ctx["authors"] = models.Author.objects.all().prefetch_related('book_set__book_set', 'translated_book_set__book_set')
20 class AuthorView(TemplateView):
22 template_name = "catalogue/author_detail.html"
24 def get_context_data(self, slug):
25 ctx = super().get_context_data()
26 authors = models.Author.objects.filter(slug=slug).prefetch_related(
28 Prefetch("translated_book_set"),
30 ctx["author"] = authors.first()
34 class BookView(DetailView):