Fix #1: 500 error when creating first book
All checks were successful
CI / quality-checks (push) Successful in 43s
All checks were successful
CI / quality-checks (push) Successful in 43s
The 500 error occurred because the create template was missing the genres, authors, and locations data needed to render the form.
This commit is contained in:
@@ -303,19 +303,21 @@ def create_book() -> ResponseReturnValue:
|
|||||||
|
|
||||||
except DuplicateISBNError as e:
|
except DuplicateISBNError as e:
|
||||||
flash(f"Error: {e}", "error")
|
flash(f"Error: {e}", "error")
|
||||||
return render_template("book/create.html.j2", form_data=request.form)
|
|
||||||
|
|
||||||
except ValidationError as e:
|
except ValidationError as e:
|
||||||
_flash_validation_errors(e)
|
_flash_validation_errors(e)
|
||||||
|
|
||||||
return render_template("book/create.html.j2", form_data=request.form)
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Error creating book '{form_data.title}': {e}", exc_info=True)
|
logger.error(f"Error creating book '{form_data.title}': {e}", exc_info=True)
|
||||||
flash(f"Error creating book: {e}", "error")
|
flash(f"Error creating book: {e}", "error")
|
||||||
return render_template("book/create.html.j2", form_data=request.form)
|
|
||||||
|
|
||||||
return render_template("book/create.html.j2")
|
return render_template(
|
||||||
|
"book/create.html.j2",
|
||||||
|
form_data=request.form,
|
||||||
|
genres=library.list_genres(),
|
||||||
|
authors=library.list_authors(),
|
||||||
|
locations=library.list_locations(),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/book/<int:book_id>/edit", methods=["POST"])
|
@bp.route("/book/<int:book_id>/edit", methods=["POST"])
|
||||||
|
|||||||
Reference in New Issue
Block a user