mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-23 16:40:36 +00:00
Use False instead of None for test values
This commit is contained in:
parent
1e4aee8276
commit
02dd1e9443
2 changed files with 5 additions and 4 deletions
|
@ -376,7 +376,8 @@ class Review(BookStatus):
|
|||
|
||||
def save(self, *args, **kwargs):
|
||||
"""clear rating caches"""
|
||||
cache.delete(f"book-rating-{self.book.parent_work.id}-*")
|
||||
if self.book.parent_work:
|
||||
cache.delete(f"book-rating-{self.book.parent_work.id}-*")
|
||||
super().save(*args, **kwargs)
|
||||
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ def get_rating(book, user):
|
|||
f"book-rating-{book.parent_work.id}-{user.id}",
|
||||
lambda u, b: models.Review.privacy_filter(u)
|
||||
.filter(book__parent_work__editions=b)
|
||||
.aggregate(Avg("rating"))["rating__avg"],
|
||||
.aggregate(Avg("rating"))["rating__avg"] or 0,
|
||||
user,
|
||||
book,
|
||||
timeout=15552000,
|
||||
|
@ -144,7 +144,7 @@ def active_shelf(context, book):
|
|||
models.ShelfBook.objects.filter(
|
||||
shelf__user=u,
|
||||
book__parent_work__editions=b,
|
||||
).first()
|
||||
).first() or False
|
||||
),
|
||||
user,
|
||||
book,
|
||||
|
@ -162,7 +162,7 @@ def latest_read_through(book, user):
|
|||
lambda u, b: (
|
||||
models.ReadThrough.objects.filter(user=u, book=b, is_active=True)
|
||||
.order_by("-start_date")
|
||||
.first()
|
||||
.first() or False
|
||||
),
|
||||
user,
|
||||
book,
|
||||
|
|
Loading…
Reference in a new issue