mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-25 19:11:09 +00:00
Invalidate active_shelf
when switching editions
This commit is contained in:
parent
b04ebe397b
commit
eb13eb9882
1 changed files with 7 additions and 0 deletions
|
@ -3,6 +3,7 @@ from functools import reduce
|
||||||
import operator
|
import operator
|
||||||
|
|
||||||
from django.contrib.auth.decorators import login_required
|
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.core.paginator import Paginator
|
||||||
from django.db import transaction
|
from django.db import transaction
|
||||||
from django.db.models import Q
|
from django.db.models import Q
|
||||||
|
@ -103,4 +104,10 @@ def switch_edition(request):
|
||||||
readthrough.book = new_edition
|
readthrough.book = new_edition
|
||||||
readthrough.save()
|
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)
|
||||||
|
]
|
||||||
|
)
|
||||||
return redirect(f"/book/{new_edition.id}")
|
return redirect(f"/book/{new_edition.id}")
|
||||||
|
|
Loading…
Reference in a new issue