feat: return-to-project redirects from create/edit forms
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -141,6 +141,8 @@ async def create_list(
|
||||
return RedirectResponse(url=f"/meetings/{meeting_id}?tab=lists", status_code=303)
|
||||
if focus_id and focus_id.strip():
|
||||
return RedirectResponse(url=f"/focus/{focus_id}?tab=lists", status_code=303)
|
||||
if project_id and project_id.strip():
|
||||
return RedirectResponse(url=f"/projects/{project_id}?tab=lists", status_code=303)
|
||||
return RedirectResponse(url=f"/lists/{new_list['id']}", status_code=303)
|
||||
|
||||
|
||||
@@ -216,7 +218,7 @@ async def list_detail(list_id: str, request: Request, db: AsyncSession = Depends
|
||||
|
||||
|
||||
@router.get("/{list_id}/edit")
|
||||
async def edit_form(list_id: str, request: Request, db: AsyncSession = Depends(get_db)):
|
||||
async def edit_form(list_id: str, request: Request, from_project: Optional[str] = None, db: AsyncSession = Depends(get_db)):
|
||||
repo = BaseRepository("lists", db)
|
||||
sidebar = await get_sidebar_data(db)
|
||||
item = await repo.get(list_id)
|
||||
@@ -236,6 +238,7 @@ async def edit_form(list_id: str, request: Request, db: AsyncSession = Depends(g
|
||||
"page_title": "Edit List", "active_nav": "lists",
|
||||
"item": item,
|
||||
"prefill_domain_id": "", "prefill_project_id": "",
|
||||
"from_project": from_project or "",
|
||||
})
|
||||
|
||||
|
||||
@@ -249,6 +252,7 @@ async def update_list(
|
||||
list_type: str = Form("checklist"),
|
||||
description: Optional[str] = Form(None),
|
||||
tags: Optional[str] = Form(None),
|
||||
from_project: Optional[str] = Form(None),
|
||||
db: AsyncSession = Depends(get_db),
|
||||
):
|
||||
repo = BaseRepository("lists", db)
|
||||
@@ -264,6 +268,12 @@ async def update_list(
|
||||
data["tags"] = None
|
||||
|
||||
await repo.update(list_id, data)
|
||||
|
||||
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=lists", status_code=303)
|
||||
return RedirectResponse(url=f"/projects/{from_project}?tab=lists", status_code=303)
|
||||
return RedirectResponse(url=f"/lists/{list_id}", status_code=303)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user