mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-10-31 22:19:00 +00:00
fix ensure_transient_values_persist call
This commit is contained in:
parent
74f08323d1
commit
6f025af99f
1 changed files with 4 additions and 4 deletions
|
@ -103,12 +103,12 @@ class CreateBook(View):
|
|||
}
|
||||
|
||||
if not form.is_valid():
|
||||
ensure_transient_values_persist(request, data, form)
|
||||
ensure_transient_values_persist(request, data, form=form)
|
||||
return TemplateResponse(request, "book/edit/edit_book.html", data)
|
||||
|
||||
# we have to call this twice because it requires form.cleaned_data
|
||||
# which only exists after we validate the form
|
||||
ensure_transient_values_persist(request, data, form)
|
||||
ensure_transient_values_persist(request, data, form=form)
|
||||
data = add_authors(request, data)
|
||||
|
||||
# check if this is an edition of an existing work
|
||||
|
@ -141,10 +141,10 @@ class CreateBook(View):
|
|||
return redirect(f"/book/{book.id}")
|
||||
|
||||
|
||||
def ensure_transient_values_persist(request, data, form):
|
||||
def ensure_transient_values_persist(request, data, **kwargs):
|
||||
"""ensure that values of transient form fields persist when re-rendering the form"""
|
||||
data["book"] = data.get("book") or {}
|
||||
data["book"]["subjects"] = form.cleaned_data["subjects"]
|
||||
data["book"]["subjects"] = kwargs["form"].cleaned_data["subjects"]
|
||||
data["add_author"] = request.POST.getlist("add_author")
|
||||
data["cover_url"] = request.POST.get("cover-url")
|
||||
|
||||
|
|
Loading…
Reference in a new issue