feat: return-to-project redirects from create/edit forms
When creating or editing items from a project detail tab, users now return to that project's tab instead of the entity's own page. Edit links pass from_project param; forms include hidden field. Reassigning to a different project redirects to the new project. Decisions/meetings create from project context inserts junction rows. File uploads from project context redirect back to project files tab. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -138,7 +138,7 @@ async def contact_detail(contact_id: str, request: Request, db: AsyncSession = D
|
||||
|
||||
|
||||
@router.get("/{contact_id}/edit")
|
||||
async def edit_form(contact_id: str, request: Request, db: AsyncSession = Depends(get_db)):
|
||||
async def edit_form(contact_id: str, request: Request, from_project: Optional[str] = None, db: AsyncSession = Depends(get_db)):
|
||||
repo = BaseRepository("contacts", db)
|
||||
sidebar = await get_sidebar_data(db)
|
||||
item = await repo.get(contact_id)
|
||||
@@ -159,6 +159,7 @@ async def edit_form(contact_id: str, request: Request, db: AsyncSession = Depend
|
||||
"request": request, "sidebar": sidebar,
|
||||
"page_title": "Edit Contact", "active_nav": "contacts",
|
||||
"item": item, "all_links": all_links, "linked_links": linked_links,
|
||||
"from_project": from_project or "",
|
||||
})
|
||||
|
||||
|
||||
@@ -174,6 +175,7 @@ async def update_contact(
|
||||
phone: Optional[str] = Form(None),
|
||||
notes: Optional[str] = Form(None),
|
||||
tags: Optional[str] = Form(None),
|
||||
from_project: Optional[str] = Form(None),
|
||||
db: AsyncSession = Depends(get_db),
|
||||
):
|
||||
repo = BaseRepository("contacts", db)
|
||||
@@ -224,6 +226,8 @@ async def update_contact(
|
||||
|
||||
await db.commit()
|
||||
|
||||
if from_project and from_project.strip():
|
||||
return RedirectResponse(url=f"/projects/{from_project}?tab=contacts", status_code=303)
|
||||
return RedirectResponse(url=f"/contacts/{contact_id}", status_code=303)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user