fnp
/
wolnelektury.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge remote-tracking branch 'zawadzki/new-design'
[wolnelektury.git]
/
src
/
catalogue
/
models
/
book.py
diff --git
a/src/catalogue/models/book.py
b/src/catalogue/models/book.py
index
ab7a591
..
ee85955
100644
(file)
--- 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:
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)
return fragments[offset : offset + number]
elif self.parent:
return self.parent.choose_fragments(number)