Fix tests

This commit is contained in:
Thomas Versteeg 2022-02-14 18:12:08 +01:00
parent c88b34814f
commit d63e5ab2d2
3 changed files with 16 additions and 19 deletions

View file

@ -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">

View file

@ -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)

View file

@ -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)