From 6eb78725980cedc29e3d2b79ec66154fc1328163 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sun, 10 Jan 2021 07:54:58 -0800 Subject: [PATCH] Fixes queryset for shelf page json --- bookwyrm/models/shelf.py | 2 +- bookwyrm/tests/test_views.py | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/bookwyrm/models/shelf.py b/bookwyrm/models/shelf.py index 69df43b4..a06f78dc 100644 --- a/bookwyrm/models/shelf.py +++ b/bookwyrm/models/shelf.py @@ -39,7 +39,7 @@ class Shelf(OrderedCollectionMixin, BookWyrmModel): @property def collection_queryset(self): ''' list of books for this shelf, overrides OrderedCollectionMixin ''' - return self.books + return self.books.all() def get_remote_id(self): ''' shelf identifier instead of id ''' diff --git a/bookwyrm/tests/test_views.py b/bookwyrm/tests/test_views.py index 9dced9c5..eee69d06 100644 --- a/bookwyrm/tests/test_views.py +++ b/bookwyrm/tests/test_views.py @@ -570,6 +570,16 @@ class Views(TestCase): self.assertEqual(result.status_code, 200) + request = self.factory.get('/?page=1') + request.user = self.local_user + with patch('bookwyrm.views.is_api_request') as is_api: + is_api.return_value = True + result = views.shelf_page( + request, self.local_user.username, shelf.identifier) + self.assertIsInstance(result, ActivitypubResponse) + self.assertEqual(result.status_code, 200) + + def test_is_bookwyrm_request(self): ''' checks if a request came from a bookwyrm instance ''' request = self.factory.get('', {'q': 'Test Book'})