Skip to content

Commit

Permalink
retain additional authors on form failure when editing book
Browse files Browse the repository at this point in the history
  • Loading branch information
hughrun committed Apr 28, 2023
1 parent 5f5886e commit 5c9b962
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions bookwyrm/views/books/edit_book.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def post(self, request, book_id):
data = {"book": book, "form": form}
ensure_transient_values_persist(request, data)
if not form.is_valid():
ensure_transient_values_persist(request, data, add_author=True)
return TemplateResponse(request, "book/edit/edit_book.html", data)

data = add_authors(request, data)
Expand Down Expand Up @@ -148,6 +149,8 @@ def ensure_transient_values_persist(request, data, **kwargs):
data["book"] = data.get("book") or {}
data["book"]["subjects"] = kwargs["form"].cleaned_data["subjects"]
data["add_author"] = request.POST.getlist("add_author")
elif kwargs and kwargs.get("add_author") is True:
data["add_author"] = request.POST.getlist("add_author")


def add_authors(request, data):
Expand Down

0 comments on commit 5c9b962

Please sign in to comment.