forked from mirrors/bookwyrm
More robust user page test and bug fix
This commit is contained in:
parent
7ffc300bb1
commit
b22d1863c9
3 changed files with 11 additions and 3 deletions
|
@ -30,6 +30,14 @@ class UserViews(TestCase):
|
||||||
self.rat = models.User.objects.create_user(
|
self.rat = models.User.objects.create_user(
|
||||||
"rat@local.com", "rat@rat.rat", "password", local=True, localname="rat"
|
"rat@local.com", "rat@rat.rat", "password", local=True, localname="rat"
|
||||||
)
|
)
|
||||||
|
self.book = models.Edition.objects.create(title="test")
|
||||||
|
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||||
|
models.ShelfBook.objects.create(
|
||||||
|
book=self.book,
|
||||||
|
user=self.local_user,
|
||||||
|
shelf=self.local_user.shelf_set.first(),
|
||||||
|
)
|
||||||
|
|
||||||
models.SiteSettings.objects.create()
|
models.SiteSettings.objects.create()
|
||||||
self.anonymous_user = AnonymousUser
|
self.anonymous_user = AnonymousUser
|
||||||
self.anonymous_user.is_authenticated = False
|
self.anonymous_user.is_authenticated = False
|
||||||
|
|
|
@ -270,10 +270,10 @@ class Editions(View):
|
||||||
if request.GET.get("format"):
|
if request.GET.get("format"):
|
||||||
filters["physical_format__iexact"] = request.GET.get("format")
|
filters["physical_format__iexact"] = request.GET.get("format")
|
||||||
|
|
||||||
editions = work.editions.order_by("-edition_rank").all()
|
editions = work.editions.order_by("-edition_rank")
|
||||||
languages = set(sum([e.languages for e in editions], []))
|
languages = set(sum([e.languages for e in editions], []))
|
||||||
|
|
||||||
paginated = Paginator(editions.filter(**filters).all(), PAGE_LENGTH)
|
paginated = Paginator(editions.filter(**filters), PAGE_LENGTH)
|
||||||
data = {
|
data = {
|
||||||
"editions": paginated.get_page(request.GET.get("page")),
|
"editions": paginated.get_page(request.GET.get("page")),
|
||||||
"work": work,
|
"work": work,
|
||||||
|
|
|
@ -59,7 +59,7 @@ class User(View):
|
||||||
{
|
{
|
||||||
"name": user_shelf.name,
|
"name": user_shelf.name,
|
||||||
"local_path": user_shelf.local_path,
|
"local_path": user_shelf.local_path,
|
||||||
"books": user_shelf.books[:3],
|
"books": user_shelf.books.all()[:3],
|
||||||
"size": user_shelf.books.count(),
|
"size": user_shelf.books.count(),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue