From: Radek Czajka Date: Thu, 3 Feb 2022 12:04:46 +0000 (+0100) Subject: New version fixes. X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/4e1c1595fef6c3b682170a34533edaf88e268d1f?hp=90b19d6345ba7e64c666aca728ca6fc351c37995 New version fixes. --- diff --git a/src/catalogue/models/book.py b/src/catalogue/models/book.py index ab7a59106..ee8595588 100644 --- a/src/catalogue/models/book.py +++ b/src/catalogue/models/book.py @@ -912,7 +912,10 @@ class Book(models.Model): fragments = Fragment.objects.filter(book__ancestor=self).order_by() fragments_count = fragments.count() if fragments_count: - offset = randint(0, fragments_count - number) + if fragments_count > number: + offset = randint(0, fragments_count - number) + else: + offset = 0 return fragments[offset : offset + number] elif self.parent: return self.parent.choose_fragments(number) diff --git a/src/catalogue/templates/catalogue/2021/book_detail.html b/src/catalogue/templates/catalogue/2021/book_detail.html index f7261ec31..05639bfeb 100644 --- a/src/catalogue/templates/catalogue/2021/book_detail.html +++ b/src/catalogue/templates/catalogue/2021/book_detail.html @@ -30,7 +30,7 @@