forked from mirrors/bookwyrm
Fix tests
This commit is contained in:
parent
c88b34814f
commit
d63e5ab2d2
3 changed files with 16 additions and 19 deletions
|
@ -20,10 +20,10 @@ Stop Reading "<em>{{ book_title }}</em>"
|
|||
<div class="columns">
|
||||
<div class="column is-half">
|
||||
<div class="field">
|
||||
<label class="label" for="finish_id_start_date_{{ uuid }}">
|
||||
<label class="label" for="stop_id_start_date_{{ uuid }}">
|
||||
{% trans "Started reading" %}
|
||||
</label>
|
||||
<input type="date" name="start_date" class="input" id="finish_id_start_date_{{ uuid }}" value="{{ readthrough.start_date | date:"Y-m-d" }}">
|
||||
<input type="date" name="start_date" class="input" id="stop_id_start_date_{{ uuid }}" value="{{ readthrough.start_date | date:"Y-m-d" }}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="column is-half">
|
||||
|
|
|
@ -36,22 +36,19 @@ 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)
|
||||
|
|
|
@ -53,7 +53,7 @@ class User(TestCase):
|
|||
|
||||
def test_user_shelves(self):
|
||||
shelves = models.Shelf.objects.filter(user=self.user).all()
|
||||
self.assertEqual(len(shelves), 3)
|
||||
self.assertEqual(len(shelves), 4)
|
||||
names = [s.name for s in shelves]
|
||||
self.assertTrue("To Read" in names)
|
||||
self.assertTrue("Currently Reading" in names)
|
||||
|
|
Loading…
Reference in a new issue