mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2025-01-02 05:18:43 +00:00
black
This commit is contained in:
parent
9031184176
commit
602c8c83ba
2 changed files with 12 additions and 14 deletions
|
@ -361,7 +361,8 @@ class ListViews(TestCase):
|
||||||
|
|
||||||
remove_request = self.factory.post("", {"item": items[1].id})
|
remove_request = self.factory.post("", {"item": items[1].id})
|
||||||
remove_request.user = self.local_user
|
remove_request.user = self.local_user
|
||||||
views.list.remove_book(remove_request, self.list.id)
|
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||||
|
views.list.remove_book(remove_request, self.list.id)
|
||||||
items = self.list.listitem_set.order_by("order").all()
|
items = self.list.listitem_set.order_by("order").all()
|
||||||
self.assertEqual(items[0].book, self.book)
|
self.assertEqual(items[0].book, self.book)
|
||||||
self.assertEqual(items[1].book, self.book_three)
|
self.assertEqual(items[1].book, self.book_three)
|
||||||
|
@ -415,7 +416,8 @@ class ListViews(TestCase):
|
||||||
|
|
||||||
set_position_request = self.factory.post("", {"position": 1})
|
set_position_request = self.factory.post("", {"position": 1})
|
||||||
set_position_request.user = self.local_user
|
set_position_request.user = self.local_user
|
||||||
views.list.set_book_position(set_position_request, items[2].id)
|
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||||
|
views.list.set_book_position(set_position_request, items[2].id)
|
||||||
items = self.list.listitem_set.order_by("order").all()
|
items = self.list.listitem_set.order_by("order").all()
|
||||||
self.assertEqual(items[0].book, self.book_three)
|
self.assertEqual(items[0].book, self.book_three)
|
||||||
self.assertEqual(items[1].book, self.book)
|
self.assertEqual(items[1].book, self.book)
|
||||||
|
|
|
@ -124,27 +124,23 @@ class List(View):
|
||||||
directional_sort_by = "-" + directional_sort_by
|
directional_sort_by = "-" + directional_sort_by
|
||||||
|
|
||||||
if sort_by == "order":
|
if sort_by == "order":
|
||||||
items = (
|
items = book_list.listitem_set.filter(approved=True).order_by(
|
||||||
book_list.listitem_set
|
directional_sort_by
|
||||||
.filter(approved=True)
|
|
||||||
.order_by(directional_sort_by)
|
|
||||||
)
|
)
|
||||||
elif sort_by == "title":
|
elif sort_by == "title":
|
||||||
items = (
|
items = book_list.listitem_set.filter(approved=True).order_by(
|
||||||
book_list.listitem_set
|
directional_sort_by
|
||||||
.filter(approved=True)
|
|
||||||
.order_by(
|
|
||||||
directional_sort_by)
|
|
||||||
)
|
)
|
||||||
elif sort_by == "rating":
|
elif sort_by == "rating":
|
||||||
items = (
|
items = (
|
||||||
book_list.listitem_set
|
book_list.listitem_set.annotate(
|
||||||
.annotate(average_rating=Avg(Coalesce("book__review__rating", 0)))
|
average_rating=Avg(Coalesce("book__review__rating", 0))
|
||||||
|
)
|
||||||
.filter(approved=True)
|
.filter(approved=True)
|
||||||
.order_by(directional_sort_by)
|
.order_by(directional_sort_by)
|
||||||
)
|
)
|
||||||
|
|
||||||
paginated = Paginator(items, 2)
|
paginated = Paginator(items, 25)
|
||||||
|
|
||||||
if query and request.user.is_authenticated:
|
if query and request.user.is_authenticated:
|
||||||
# search for books
|
# search for books
|
||||||
|
|
Loading…
Reference in a new issue