From 68d943fb26987388a0a41885a63227b3dfabff64 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Tue, 11 Jan 2022 10:33:58 -0800 Subject: [PATCH] Preserve readthrough id in edit --- bookwyrm/templates/readthrough/readthrough.html | 2 +- bookwyrm/views/reading.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/bookwyrm/templates/readthrough/readthrough.html b/bookwyrm/templates/readthrough/readthrough.html index bed59d29b..0b42017e6 100644 --- a/bookwyrm/templates/readthrough/readthrough.html +++ b/bookwyrm/templates/readthrough/readthrough.html @@ -4,7 +4,7 @@ {% block title %} {% blocktrans trimmed with title=book|book_title %} -Add read dates for "{{ title }}" +Update read dates for "{{ title }}" {% endblocktrans %} {% endblock %} diff --git a/bookwyrm/views/reading.py b/bookwyrm/views/reading.py index 7c2b6d0bd..22ee450ad 100644 --- a/bookwyrm/views/reading.py +++ b/bookwyrm/views/reading.py @@ -137,6 +137,10 @@ class CreateReadThrough(View): if not form.is_valid(): book = get_object_or_404(models.Edition, id=book_id) data = {"form": form, "book": book} + if request.POST.get("id"): + data["readthrough"] = get_object_or_404( + models.ReadThrough, id=request.POST.get("id") + ) return TemplateResponse( request, "readthrough/readthrough.html", data ) @@ -144,7 +148,6 @@ class CreateReadThrough(View): return redirect("book", book_id) - @transaction.atomic def update_readthrough_on_shelve( user, annotated_book, status, start_date=None, finish_date=None