Links and Other Enhancements

This commit is contained in:
2026-03-02 19:55:04 +00:00
parent cf84d6d2dd
commit 0ed86ee2dc
24 changed files with 475 additions and 153 deletions

View File

@@ -192,6 +192,7 @@ async def project_detail(
links = []
tab_data = []
all_contacts = []
all_meetings = []
if tab == "notes":
result = await db.execute(text("""
@@ -235,6 +236,21 @@ async def project_detail(
"""), {"pid": project_id})
tab_data = [dict(r._mapping) for r in result]
elif tab == "meetings":
result = await db.execute(text("""
SELECT m.*, pm.created_at as linked_at
FROM meetings m
JOIN project_meetings pm ON pm.meeting_id = m.id
WHERE pm.project_id = :pid AND m.is_deleted = false
ORDER BY m.meeting_date DESC, m.start_at DESC NULLS LAST
"""), {"pid": project_id})
tab_data = [dict(r._mapping) for r in result]
result = await db.execute(text("""
SELECT id, title, meeting_date FROM meetings
WHERE is_deleted = false ORDER BY meeting_date DESC LIMIT 50
"""))
all_meetings = [dict(r._mapping) for r in result]
elif tab == "contacts":
result = await db.execute(text("""
SELECT c.*, cp.role, cp.created_at as linked_at
@@ -258,6 +274,7 @@ async def project_detail(
("files", "SELECT count(*) FROM files f JOIN file_mappings fm ON fm.file_id = f.id WHERE fm.context_type = 'project' AND fm.context_id = :pid AND f.is_deleted = false"),
("lists", "SELECT count(*) FROM lists WHERE project_id = :pid AND is_deleted = false"),
("decisions", "SELECT count(*) FROM decisions d JOIN decision_projects dp ON dp.decision_id = d.id WHERE dp.project_id = :pid AND d.is_deleted = false"),
("meetings", "SELECT count(*) FROM meetings m JOIN project_meetings pm ON pm.meeting_id = m.id WHERE pm.project_id = :pid AND m.is_deleted = false"),
("contacts", "SELECT count(*) FROM contacts c JOIN contact_projects cp ON cp.contact_id = c.id WHERE cp.project_id = :pid AND c.is_deleted = false"),
]:
result = await db.execute(text(count_sql), {"pid": project_id})
@@ -267,7 +284,8 @@ async def project_detail(
"request": request, "sidebar": sidebar, "item": item,
"domain": domain, "area": area,
"tasks": tasks, "notes": notes, "links": links,
"tab_data": tab_data, "all_contacts": all_contacts, "counts": counts,
"tab_data": tab_data, "all_contacts": all_contacts,
"all_meetings": all_meetings, "counts": counts,
"progress": progress, "task_count": total, "done_count": done,
"tab": tab,
"page_title": item["name"], "active_nav": "projects",
@@ -332,6 +350,32 @@ async def delete_project(project_id: str, db: AsyncSession = Depends(get_db)):
return RedirectResponse(url="/projects", status_code=303)
# ---- Meeting linking ----
@router.post("/{project_id}/meetings/add")
async def add_meeting(
project_id: str,
meeting_id: str = Form(...),
db: AsyncSession = Depends(get_db),
):
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)
@router.post("/{project_id}/meetings/{meeting_id}/remove")
async def remove_meeting(
project_id: str, meeting_id: str,
db: AsyncSession = Depends(get_db),
):
await db.execute(text(
"DELETE FROM project_meetings WHERE project_id = :pid AND meeting_id = :mid"
), {"pid": project_id, "mid": meeting_id})
return RedirectResponse(url=f"/projects/{project_id}?tab=meetings", status_code=303)
# ---- Contact linking ----
@router.post("/{project_id}/contacts/add")