mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-24 02:21:04 +00:00
delete and re-add shelf books in switch edition
This commit is contained in:
parent
9561bb2294
commit
0682117a06
1 changed files with 8 additions and 3 deletions
|
@ -211,9 +211,14 @@ def switch_edition(request):
|
||||||
shelf__user=request.user
|
shelf__user=request.user
|
||||||
)
|
)
|
||||||
for shelfbook in shelfbooks.all():
|
for shelfbook in shelfbooks.all():
|
||||||
# TODO: this needs to be a delete and re-create
|
with transaction.atomic():
|
||||||
shelfbook.book = new_edition
|
models.ShelfBook.objects.create(
|
||||||
shelfbook.save()
|
created_date=shelfbook.created_date,
|
||||||
|
user=shelfbook.user,
|
||||||
|
shelf=shelfbook.shelf,
|
||||||
|
book=new_edition
|
||||||
|
)
|
||||||
|
shelfbook.delete()
|
||||||
|
|
||||||
readthroughs = models.ReadThrough.objects.filter(
|
readthroughs = models.ReadThrough.objects.filter(
|
||||||
book__parent_work=new_edition.parent_work,
|
book__parent_work=new_edition.parent_work,
|
||||||
|
|
Loading…
Reference in a new issue