mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-26 19:41:11 +00:00
run black, add a try/catch around the formcopy fix
This commit is contained in:
parent
0941c50c69
commit
51e16fba97
1 changed files with 12 additions and 2 deletions
|
@ -176,8 +176,18 @@ class EditBook(View):
|
|||
# we have to make sure the dates are passed in as datetime, they're currently a string
|
||||
# QueryDicts are immutable, we need to copy
|
||||
formcopy = data["form"].data.copy()
|
||||
formcopy["first_published_date"] = datetime.strptime(formcopy["first_published_date"], "%Y-%m-%d")
|
||||
formcopy["published_date"] = datetime.strptime(formcopy["published_date"], "%Y-%m-%d")
|
||||
try:
|
||||
formcopy["first_published_date"] = datetime.strptime(
|
||||
formcopy["first_published_date"], "%Y-%m-%d"
|
||||
)
|
||||
except MultiValueDictKeyError:
|
||||
pass
|
||||
try:
|
||||
formcopy["published_date"] = datetime.strptime(
|
||||
formcopy["published_date"], "%Y-%m-%d"
|
||||
)
|
||||
except MultiValueDictKeyError:
|
||||
pass
|
||||
data["form"].data = formcopy
|
||||
return TemplateResponse(request, "book/edit_book.html", data)
|
||||
|
||||
|
|
Loading…
Reference in a new issue