経費フォームの検証エラーでスキャン済み領収書の紐付けが失われる #1
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
レビュー指摘(deferred minor)の正式なissue化。
現象
領収書スキャン(
/expenses/scan)→フォーム初期値表示→バリデーションエラーで再表示されると、hiddenのscanned_receiptがv['receipt_filename']にマップされず消える。そのまま保存するとreceipt_filename=Noneになり、保存済み画像が孤立する。対象
app/routes/expenses.py—new_expenseのエラーパスapp/templates/expenses/form.html— hiddenフィールドの参照キー修正方針
v['receipt_filename'] = request.form.get('scanned_receipt')を補う、またはフィールド名をreceipt_filenameに統一関連
/expenses/newはバリデーション前に画像を保存するため、検証失敗でも無参照ファイルが残る。edit_expenseは検証後保存で順序が不整合。併せて「バリデーション→保存」の順に統一する。修正しました。バリデーションを先に行い、エラー再表示時も
scanned_receiptをhiddenで保持するようにしました。検証失敗時に無参照画像が残る問題(保存順序の不整合)も同時に解消。テスト70件パス。