Python formatting
This commit is contained in:
parent
76c466ee45
commit
742d97b177
3 changed files with 23 additions and 16 deletions
|
@ -104,18 +104,24 @@ class ShelfBook(CollectionItemMixin, BookWyrmModel):
|
||||||
self.user = self.shelf.user
|
self.user = self.shelf.user
|
||||||
if self.id and self.user.local:
|
if self.id and self.user.local:
|
||||||
# remove all caches related to all editions of this book
|
# remove all caches related to all editions of this book
|
||||||
cache.delete_many([
|
cache.delete_many(
|
||||||
|
[
|
||||||
f"book-on-shelf-{book.id}-{self.shelf.id}"
|
f"book-on-shelf-{book.id}-{self.shelf.id}"
|
||||||
for book in self.book.parent_work.editions.all()
|
for book in self.book.parent_work.editions.all()
|
||||||
])
|
]
|
||||||
|
)
|
||||||
super().save(*args, **kwargs)
|
super().save(*args, **kwargs)
|
||||||
|
|
||||||
def delete(self, *args, **kwargs):
|
def delete(self, *args, **kwargs):
|
||||||
if self.id and self.user.local:
|
if self.id and self.user.local:
|
||||||
cache.delete_many([
|
cache.delete_many(
|
||||||
|
[
|
||||||
f"book-on-shelf-{book}-{self.shelf.id}"
|
f"book-on-shelf-{book}-{self.shelf.id}"
|
||||||
for book in self.book.parent_work.editions.values_list("id", flat=True)
|
for book in self.book.parent_work.editions.values_list(
|
||||||
])
|
"id", flat=True
|
||||||
|
)
|
||||||
|
]
|
||||||
|
)
|
||||||
super().delete(*args, **kwargs)
|
super().delete(*args, **kwargs)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|
|
@ -63,11 +63,12 @@ class ReadingStatus(View):
|
||||||
)
|
)
|
||||||
|
|
||||||
# invalidate related caches
|
# invalidate related caches
|
||||||
cache.delete_many([
|
cache.delete_many(
|
||||||
|
[
|
||||||
f"active_shelf-{request.user.id}-{ed}"
|
f"active_shelf-{request.user.id}-{ed}"
|
||||||
for ed in book.parent_work.editions.values_list("id", flat=True)
|
for ed in book.parent_work.editions.values_list("id", flat=True)
|
||||||
])
|
]
|
||||||
|
)
|
||||||
|
|
||||||
# gets the first shelf that indicates a reading status, or None
|
# gets the first shelf that indicates a reading status, or None
|
||||||
shelves = [
|
shelves = [
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue