Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalidate active_shelf when switching editions #3217

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading