Fix events: return 404 for deleted/missing calendar entries
The before_request handler loaded the entry but didn't abort when it was None, causing template UndefinedError when building URLs with entry.id. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -50,6 +50,7 @@ def register():
|
|||||||
@bp.before_request
|
@bp.before_request
|
||||||
async def load_entry():
|
async def load_entry():
|
||||||
"""Load the calendar entry from the URL parameter."""
|
"""Load the calendar entry from the URL parameter."""
|
||||||
|
from quart import abort
|
||||||
entry_id = request.view_args.get("entry_id")
|
entry_id = request.view_args.get("entry_id")
|
||||||
if entry_id:
|
if entry_id:
|
||||||
result = await g.s.execute(
|
result = await g.s.execute(
|
||||||
@@ -60,6 +61,8 @@ def register():
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
g.entry = result.scalar_one_or_none()
|
g.entry = result.scalar_one_or_none()
|
||||||
|
if g.entry is None:
|
||||||
|
abort(404)
|
||||||
|
|
||||||
@bp.context_processor
|
@bp.context_processor
|
||||||
async def inject_entry():
|
async def inject_entry():
|
||||||
|
|||||||
Reference in New Issue
Block a user