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

@@ -51,7 +51,7 @@ async def list_meetings(
@router.get("/create")
async def create_form(request: Request, db: AsyncSession = Depends(get_db)):
async def create_form(request: Request, project_id: Optional[str] = None, db: AsyncSession = Depends(get_db)):
sidebar = await get_sidebar_data(db)
# Get contacts for attendee selection
contacts_repo = BaseRepository("contacts", db)
@@ -68,6 +68,7 @@ async def create_form(request: Request, db: AsyncSession = Depends(get_db)):
"contacts": contacts, "parent_meetings": parent_meetings,
"page_title": "New Meeting", "active_nav": "meetings",
"item": None,
"prefill_project_id": project_id or "",
})
@@ -84,6 +85,7 @@ async def create_meeting(
parent_id: Optional[str] = Form(None),
agenda: Optional[str] = Form(None),
tags: Optional[str] = Form(None),
project_id: Optional[str] = Form(None),
db: AsyncSession = Depends(get_db),
):
repo = BaseRepository("meetings", db)
@@ -103,6 +105,14 @@ async def create_meeting(
data["tags"] = [t.strip() for t in tags.split(",") if t.strip()]
meeting = await repo.create(data)
# Link to project if created from project context
if project_id and project_id.strip():
await db.execute(text("""
INSERT INTO project_meetings (project_id, meeting_id)
VALUES (:pid, :mid) ON CONFLICT DO NOTHING
"""), {"pid": project_id, "mid": meeting["id"]})
return RedirectResponse(url=f"/projects/{project_id}?tab=meetings", status_code=303)
return RedirectResponse(url=f"/meetings/{meeting['id']}", status_code=303)
@@ -253,7 +263,7 @@ async def meeting_detail(
@router.get("/{meeting_id}/edit")
async def edit_form(meeting_id: str, request: Request, db: AsyncSession = Depends(get_db)):
async def edit_form(meeting_id: str, request: Request, from_project: Optional[str] = None, db: AsyncSession = Depends(get_db)):
repo = BaseRepository("meetings", db)
sidebar = await get_sidebar_data(db)
item = await repo.get(meeting_id)
@@ -273,6 +283,7 @@ async def edit_form(meeting_id: str, request: Request, db: AsyncSession = Depend
"contacts": contacts, "parent_meetings": parent_meetings,
"page_title": "Edit Meeting", "active_nav": "meetings",
"item": item,
"from_project": from_project or "",
})
@@ -291,6 +302,7 @@ async def update_meeting(
transcript: Optional[str] = Form(None),
notes_body: Optional[str] = Form(None),
tags: Optional[str] = Form(None),
from_project: Optional[str] = Form(None),
db: AsyncSession = Depends(get_db),
):
repo = BaseRepository("meetings", db)
@@ -315,6 +327,9 @@ async def update_meeting(
data["tags"] = None
await repo.update(meeting_id, data)
if from_project and from_project.strip():
return RedirectResponse(url=f"/projects/{from_project}?tab=meetings", status_code=303)
return RedirectResponse(url=f"/meetings/{meeting_id}", status_code=303)