diff --git a/bookwyrm/models/shelf.py b/bookwyrm/models/shelf.py index b1b99fac1..d955e8d07 100644 --- a/bookwyrm/models/shelf.py +++ b/bookwyrm/models/shelf.py @@ -104,18 +104,24 @@ class ShelfBook(CollectionItemMixin, BookWyrmModel): self.user = self.shelf.user if self.id and self.user.local: # remove all caches related to all editions of this book - cache.delete_many([ - f"book-on-shelf-{book.id}-{self.shelf.id}" - for book in self.book.parent_work.editions.all() - ]) + cache.delete_many( + [ + f"book-on-shelf-{book.id}-{self.shelf.id}" + for book in self.book.parent_work.editions.all() + ] + ) super().save(*args, **kwargs) def delete(self, *args, **kwargs): if self.id and self.user.local: - cache.delete_many([ - f"book-on-shelf-{book}-{self.shelf.id}" - for book in self.book.parent_work.editions.values_list("id", flat=True) - ]) + cache.delete_many( + [ + f"book-on-shelf-{book}-{self.shelf.id}" + for book in self.book.parent_work.editions.values_list( + "id", flat=True + ) + ] + ) super().delete(*args, **kwargs) class Meta: diff --git a/bookwyrm/templatetags/shelf_tags.py b/bookwyrm/templatetags/shelf_tags.py index 51e3db8ab..1fb799883 100644 --- a/bookwyrm/templatetags/shelf_tags.py +++ b/bookwyrm/templatetags/shelf_tags.py @@ -17,7 +17,7 @@ def get_is_book_on_shelf(book, shelf): lambda b, s: s.books.filter(id=b.id).exists(), book, shelf, - timeout=60*60, # just cache this for an hour + timeout=60 * 60, # just cache this for an hour ) @@ -68,7 +68,7 @@ def active_shelf(context, book): ), user, book, - timeout=60*60, + timeout=60 * 60, ) or {"book": book} @@ -85,5 +85,5 @@ def latest_read_through(book, user): ), user, book, - timeout=60*60, + timeout=60 * 60, ) diff --git a/bookwyrm/views/reading.py b/bookwyrm/views/reading.py index e168021d2..eb43e4ea4 100644 --- a/bookwyrm/views/reading.py +++ b/bookwyrm/views/reading.py @@ -63,11 +63,12 @@ class ReadingStatus(View): ) # invalidate related caches - cache.delete_many([ - f"active_shelf-{request.user.id}-{ed}" - for ed in book.parent_work.editions.values_list("id", flat=True) - ]) - + cache.delete_many( + [ + f"active_shelf-{request.user.id}-{ed}" + for ed in book.parent_work.editions.values_list("id", flat=True) + ] + ) # gets the first shelf that indicates a reading status, or None shelves = [