Fix #1: 500 error when creating first book
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:
2026-03-31 20:00:31 +02:00
parent 03a5b3803e
commit dc73de6799

View File

@@ -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"])