feat: return-to-project redirects from create/edit forms

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-06 18:28:41 +00:00
parent 7c724f05dd
commit 404ead7596
18 changed files with 125 additions and 27 deletions

View File

@@ -322,7 +322,7 @@ async def task_detail(
@router.get("/{task_id}/edit")
async def edit_form(task_id: str, request: Request, db: AsyncSession = Depends(get_db)):
async def edit_form(task_id: str, request: Request, from_project: Optional[str] = None, db: AsyncSession = Depends(get_db)):
repo = BaseRepository("tasks", db)
sidebar = await get_sidebar_data(db)
item = await repo.get(task_id)
@@ -344,6 +344,7 @@ async def edit_form(task_id: str, request: Request, db: AsyncSession = Depends(g
"page_title": f"Edit Task", "active_nav": "tasks",
"item": item,
"prefill_domain_id": "", "prefill_project_id": "", "prefill_parent_id": "",
"from_project": from_project or "",
})
@@ -363,6 +364,7 @@ async def update_task(
tags: Optional[str] = Form(None),
estimated_minutes: Optional[str] = Form(None),
energy_required: Optional[str] = Form(None),
from_project: Optional[str] = Form(None),
db: AsyncSession = Depends(get_db),
):
repo = BaseRepository("tasks", db)
@@ -392,6 +394,13 @@ async def update_task(
data["completed_at"] = None
await repo.update(task_id, data)
# Redirect back to project context if applicable
new_project = data.get("project_id")
if from_project and from_project.strip():
if new_project and new_project != from_project:
return RedirectResponse(url=f"/projects/{new_project}?tab=tasks", status_code=303)
return RedirectResponse(url=f"/projects/{from_project}?tab=tasks", status_code=303)
return RedirectResponse(url=f"/tasks/{task_id}", status_code=303)