feat: return-to-project redirects from create/edit forms
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -416,7 +416,7 @@ async def reorder_focus_list_items(
|
||||
|
||||
|
||||
@router.get("/{focus_id}/edit")
|
||||
async def edit_focus_item(focus_id: str, request: Request, db: AsyncSession = Depends(get_db)):
|
||||
async def edit_focus_item(focus_id: str, request: Request, from_project: Optional[str] = None, db: AsyncSession = Depends(get_db)):
|
||||
repo = BaseRepository("daily_focus", db)
|
||||
item = await repo.get(focus_id)
|
||||
if not item or item.get("task_id") or item.get("list_item_id"):
|
||||
@@ -429,6 +429,7 @@ async def edit_focus_item(focus_id: str, request: Request, db: AsyncSession = De
|
||||
"request": request, "sidebar": sidebar, "item": item,
|
||||
"domains": domains, "projects": projects, "lists": lists,
|
||||
"page_title": "Edit Focus Item", "active_nav": "focus",
|
||||
"from_project": from_project or "",
|
||||
})
|
||||
|
||||
|
||||
@@ -438,14 +439,21 @@ async def update_focus_item(
|
||||
title: str = Form(...),
|
||||
domain_id: Optional[str] = Form(None),
|
||||
project_id: Optional[str] = Form(None),
|
||||
from_project: Optional[str] = Form(None),
|
||||
db: AsyncSession = Depends(get_db),
|
||||
):
|
||||
repo = BaseRepository("daily_focus", db)
|
||||
new_project = project_id if project_id and project_id.strip() else None
|
||||
await repo.update(focus_id, {
|
||||
"title": title.strip(),
|
||||
"domain_id": domain_id or None,
|
||||
"project_id": project_id or None,
|
||||
"project_id": new_project,
|
||||
})
|
||||
|
||||
if from_project and from_project.strip():
|
||||
if new_project and new_project != from_project:
|
||||
return RedirectResponse(url=f"/projects/{new_project}?tab=focus", status_code=303)
|
||||
return RedirectResponse(url=f"/projects/{from_project}?tab=focus", status_code=303)
|
||||
return RedirectResponse(url=f"/focus/{focus_id}", status_code=303)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user