mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-15 21:31:26 +00:00
Updates tests
This commit is contained in:
parent
9827cef9a9
commit
7fdf07c6ec
1 changed files with 16 additions and 13 deletions
|
@ -36,19 +36,22 @@ def get_next_shelf(current_shelf):
|
|||
def active_shelf(context, book):
|
||||
"""check what shelf a user has a book on, if any"""
|
||||
user = context["request"].user
|
||||
return cache.get_or_set(
|
||||
f"active_shelf-{user.id}-{book.id}",
|
||||
lambda u, b: (
|
||||
models.ShelfBook.objects.filter(
|
||||
shelf__user=u,
|
||||
book__parent_work__editions=b,
|
||||
).first()
|
||||
or False
|
||||
),
|
||||
user,
|
||||
book,
|
||||
timeout=15552000,
|
||||
) or {"book": book}
|
||||
return (
|
||||
cache.get_or_set(
|
||||
f"active_shelf-{user.id}-{book.id}",
|
||||
lambda u, b: (
|
||||
models.ShelfBook.objects.filter(
|
||||
shelf__user=u,
|
||||
book__parent_work__editions=b,
|
||||
).first()
|
||||
or False
|
||||
),
|
||||
user,
|
||||
book,
|
||||
timeout=15552000,
|
||||
)
|
||||
or {"book": book}
|
||||
)
|
||||
|
||||
|
||||
@register.simple_tag(takes_context=False)
|
||||
|
|
Loading…
Reference in a new issue