Merge pull request #523 from cincodenada/fix-ordering-warning

Add order for shelf books to satisfy warning
This commit is contained in:
Mouse Reeve 2021-01-17 11:35:54 -08:00 committed by GitHub
commit 48febecf0d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View file

@ -225,6 +225,9 @@ class OrderedCollectionPageMixin(ActivitypubMixin):
def to_ordered_collection(self, queryset, \
remote_id=None, page=False, **kwargs):
''' an ordered collection of whatevers '''
if not queryset.ordered:
raise RuntimeError('queryset must be ordered')
remote_id = remote_id or self.remote_id
if page:
return to_ordered_collection_page(

View file

@ -39,7 +39,7 @@ class Shelf(OrderedCollectionMixin, BookWyrmModel):
@property
def collection_queryset(self):
''' list of books for this shelf, overrides OrderedCollectionMixin '''
return self.books.all()
return self.books.all().order_by('shelfbook')
def get_remote_id(self):
''' shelf identifier instead of id '''
@ -90,3 +90,4 @@ class ShelfBook(ActivitypubMixin, BookWyrmModel):
''' an opinionated constraint!
you can't put a book on shelf twice '''
unique_together = ('book', 'shelf')
ordering = ('-created_date',)