mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2025-01-22 23:18:08 +00:00
Merge pull request #523 from cincodenada/fix-ordering-warning
Add order for shelf books to satisfy warning
This commit is contained in:
commit
48febecf0d
2 changed files with 5 additions and 1 deletions
|
@ -225,6 +225,9 @@ class OrderedCollectionPageMixin(ActivitypubMixin):
|
||||||
def to_ordered_collection(self, queryset, \
|
def to_ordered_collection(self, queryset, \
|
||||||
remote_id=None, page=False, **kwargs):
|
remote_id=None, page=False, **kwargs):
|
||||||
''' an ordered collection of whatevers '''
|
''' an ordered collection of whatevers '''
|
||||||
|
if not queryset.ordered:
|
||||||
|
raise RuntimeError('queryset must be ordered')
|
||||||
|
|
||||||
remote_id = remote_id or self.remote_id
|
remote_id = remote_id or self.remote_id
|
||||||
if page:
|
if page:
|
||||||
return to_ordered_collection_page(
|
return to_ordered_collection_page(
|
||||||
|
|
|
@ -39,7 +39,7 @@ class Shelf(OrderedCollectionMixin, BookWyrmModel):
|
||||||
@property
|
@property
|
||||||
def collection_queryset(self):
|
def collection_queryset(self):
|
||||||
''' list of books for this shelf, overrides OrderedCollectionMixin '''
|
''' list of books for this shelf, overrides OrderedCollectionMixin '''
|
||||||
return self.books.all()
|
return self.books.all().order_by('shelfbook')
|
||||||
|
|
||||||
def get_remote_id(self):
|
def get_remote_id(self):
|
||||||
''' shelf identifier instead of id '''
|
''' shelf identifier instead of id '''
|
||||||
|
@ -90,3 +90,4 @@ class ShelfBook(ActivitypubMixin, BookWyrmModel):
|
||||||
''' an opinionated constraint!
|
''' an opinionated constraint!
|
||||||
you can't put a book on shelf twice '''
|
you can't put a book on shelf twice '''
|
||||||
unique_together = ('book', 'shelf')
|
unique_together = ('book', 'shelf')
|
||||||
|
ordering = ('-created_date',)
|
||||||
|
|
Loading…
Reference in a new issue