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="columns">
|
||||||
<div class="column is-half">
|
<div class="column is-half">
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label class="label" for="finish_id_start_date_{{ uuid }}">
|
<label class="label" for="stop_id_start_date_{{ uuid }}">
|
||||||
{% trans "Started reading" %}
|
{% trans "Started reading" %}
|
||||||
</label>
|
</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>
|
</div>
|
||||||
<div class="column is-half">
|
<div class="column is-half">
|
||||||
|
|
|
@ -36,8 +36,7 @@ def get_next_shelf(current_shelf):
|
||||||
def active_shelf(context, book):
|
def active_shelf(context, book):
|
||||||
"""check what shelf a user has a book on, if any"""
|
"""check what shelf a user has a book on, if any"""
|
||||||
user = context["request"].user
|
user = context["request"].user
|
||||||
return (
|
return cache.get_or_set(
|
||||||
cache.get_or_set(
|
|
||||||
f"active_shelf-{user.id}-{book.id}",
|
f"active_shelf-{user.id}-{book.id}",
|
||||||
lambda u, b: (
|
lambda u, b: (
|
||||||
models.ShelfBook.objects.filter(
|
models.ShelfBook.objects.filter(
|
||||||
|
@ -49,9 +48,7 @@ def active_shelf(context, book):
|
||||||
user,
|
user,
|
||||||
book,
|
book,
|
||||||
timeout=15552000,
|
timeout=15552000,
|
||||||
)
|
) or {"book": book}
|
||||||
or {"book": book}
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@register.simple_tag(takes_context=False)
|
@register.simple_tag(takes_context=False)
|
||||||
|
|
|
@ -53,7 +53,7 @@ class User(TestCase):
|
||||||
|
|
||||||
def test_user_shelves(self):
|
def test_user_shelves(self):
|
||||||
shelves = models.Shelf.objects.filter(user=self.user).all()
|
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]
|
names = [s.name for s in shelves]
|
||||||
self.assertTrue("To Read" in names)
|
self.assertTrue("To Read" in names)
|
||||||
self.assertTrue("Currently Reading" in names)
|
self.assertTrue("Currently Reading" in names)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue