Preserve readthrough id in edit

This commit is contained in:
Mouse Reeve 2022-01-11 10:33:58 -08:00
parent a412f87c64
commit 68d943fb26
2 changed files with 5 additions and 2 deletions

View file

@ -4,7 +4,7 @@
{% block title %}
{% blocktrans trimmed with title=book|book_title %}
Add read dates for "<em>{{ title }}</em>"
Update read dates for "<em>{{ title }}</em>"
{% endblocktrans %}
{% endblock %}

View file

@ -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