feat: return-to-project redirects from create/edit forms
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -122,7 +122,7 @@ async def create_link(
|
||||
|
||||
|
||||
@router.get("/{link_id}/edit")
|
||||
async def edit_form(link_id: str, request: Request, db: AsyncSession = Depends(get_db)):
|
||||
async def edit_form(link_id: str, request: Request, from_project: Optional[str] = None, db: AsyncSession = Depends(get_db)):
|
||||
repo = BaseRepository("links", db)
|
||||
sidebar = await get_sidebar_data(db)
|
||||
item = await repo.get(link_id)
|
||||
@@ -138,6 +138,7 @@ async def edit_form(link_id: str, request: Request, db: AsyncSession = Depends(g
|
||||
"item": item,
|
||||
"prefill_domain_id": "", "prefill_project_id": "",
|
||||
"prefill_task_id": "", "prefill_meeting_id": "",
|
||||
"from_project": from_project or "",
|
||||
})
|
||||
|
||||
|
||||
@@ -146,6 +147,7 @@ async def update_link(
|
||||
link_id: str, label: str = Form(...), url: str = Form(...),
|
||||
domain_id: Optional[str] = Form(None), project_id: Optional[str] = Form(None),
|
||||
description: Optional[str] = Form(None), tags: Optional[str] = Form(None),
|
||||
from_project: Optional[str] = Form(None),
|
||||
db: AsyncSession = Depends(get_db),
|
||||
):
|
||||
repo = BaseRepository("links", db)
|
||||
@@ -160,6 +162,12 @@ async def update_link(
|
||||
else:
|
||||
data["tags"] = None
|
||||
await repo.update(link_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=links", status_code=303)
|
||||
return RedirectResponse(url=f"/projects/{from_project}?tab=links", status_code=303)
|
||||
return RedirectResponse(url="/links", status_code=303)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user