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:
@@ -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)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user