Skip to content

Commit

Permalink
Merge pull request #3217 from dato/switch_edition_invalidate_active_s…
Browse files Browse the repository at this point in the history
…helves

Invalidate `active_shelf` when switching editions
  • Loading branch information
mouse-reeve authored Mar 23, 2024
2 parents b508b4c + 8e088a6 commit 8bbac45
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions bookwyrm/views/books/editions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import operator

from django.contrib.auth.decorators import login_required
from django.core.cache import cache as django_cache
from django.core.paginator import Paginator
from django.db import transaction
from django.db.models import Q
Expand Down Expand Up @@ -104,6 +105,13 @@ def switch_edition(request):
readthrough.book = new_edition
readthrough.save()

django_cache.delete_many(
[
f"active_shelf-{request.user.id}-{book_id}"
for book_id in new_edition.parent_work.editions.values_list("id", flat=True)
]
)

reviews = models.Review.objects.filter(
book__parent_work=new_edition.parent_work, user=request.user
)
Expand Down

0 comments on commit 8bbac45

Please sign in to comment.