Links and Other Enhancements
This commit is contained in:
@@ -118,12 +118,24 @@ async def meeting_detail(
|
||||
if not item:
|
||||
return RedirectResponse(url="/meetings", status_code=303)
|
||||
|
||||
# Linked projects (always shown in header)
|
||||
result = await db.execute(text("""
|
||||
SELECT p.id, p.name, d.color as domain_color
|
||||
FROM projects p
|
||||
JOIN project_meetings pm ON pm.project_id = p.id
|
||||
LEFT JOIN domains d ON p.domain_id = d.id
|
||||
WHERE pm.meeting_id = :mid AND p.is_deleted = false
|
||||
ORDER BY p.name
|
||||
"""), {"mid": meeting_id})
|
||||
projects = [dict(r._mapping) for r in result]
|
||||
|
||||
# Overview data (always needed for overview tab)
|
||||
action_items = []
|
||||
decisions = []
|
||||
domains = []
|
||||
tab_data = []
|
||||
all_contacts = []
|
||||
all_decisions = []
|
||||
|
||||
if tab == "overview":
|
||||
# Action items
|
||||
@@ -160,9 +172,9 @@ async def meeting_detail(
|
||||
"""), {"mid": meeting_id})
|
||||
tab_data = [dict(r._mapping) for r in result]
|
||||
|
||||
elif tab == "weblinks":
|
||||
elif tab == "links":
|
||||
result = await db.execute(text("""
|
||||
SELECT * FROM weblinks
|
||||
SELECT * FROM links
|
||||
WHERE meeting_id = :mid AND is_deleted = false
|
||||
ORDER BY sort_order, label
|
||||
"""), {"mid": meeting_id})
|
||||
@@ -187,6 +199,20 @@ async def meeting_detail(
|
||||
"""), {"mid": meeting_id})
|
||||
tab_data = [dict(r._mapping) for r in result]
|
||||
|
||||
elif tab == "decisions":
|
||||
result = await db.execute(text("""
|
||||
SELECT * FROM decisions
|
||||
WHERE meeting_id = :mid AND is_deleted = false
|
||||
ORDER BY created_at DESC
|
||||
"""), {"mid": meeting_id})
|
||||
tab_data = [dict(r._mapping) for r in result]
|
||||
result = await db.execute(text("""
|
||||
SELECT id, title FROM decisions
|
||||
WHERE (meeting_id IS NULL) AND is_deleted = false
|
||||
ORDER BY created_at DESC LIMIT 50
|
||||
"""))
|
||||
all_decisions = [dict(r._mapping) for r in result]
|
||||
|
||||
elif tab == "contacts":
|
||||
result = await db.execute(text("""
|
||||
SELECT c.*, cm.role, cm.created_at as linked_at
|
||||
@@ -206,9 +232,10 @@ async def meeting_detail(
|
||||
counts = {}
|
||||
for count_tab, count_sql in [
|
||||
("notes", "SELECT count(*) FROM notes WHERE meeting_id = :mid AND is_deleted = false"),
|
||||
("weblinks", "SELECT count(*) FROM weblinks WHERE meeting_id = :mid AND is_deleted = false"),
|
||||
("links", "SELECT count(*) FROM links WHERE meeting_id = :mid AND is_deleted = false"),
|
||||
("files", "SELECT count(*) FROM files f JOIN file_mappings fm ON fm.file_id = f.id WHERE fm.context_type = 'meeting' AND fm.context_id = :mid AND f.is_deleted = false"),
|
||||
("lists", "SELECT count(*) FROM lists WHERE meeting_id = :mid AND is_deleted = false"),
|
||||
("decisions", "SELECT count(*) FROM decisions WHERE meeting_id = :mid AND is_deleted = false"),
|
||||
("contacts", "SELECT count(*) FROM contacts c JOIN contact_meetings cm ON cm.contact_id = c.id WHERE cm.meeting_id = :mid AND c.is_deleted = false"),
|
||||
]:
|
||||
result = await db.execute(text(count_sql), {"mid": meeting_id})
|
||||
@@ -217,8 +244,10 @@ async def meeting_detail(
|
||||
return templates.TemplateResponse("meeting_detail.html", {
|
||||
"request": request, "sidebar": sidebar, "item": item,
|
||||
"action_items": action_items, "decisions": decisions,
|
||||
"domains": domains, "tab": tab, "tab_data": tab_data,
|
||||
"all_contacts": all_contacts, "counts": counts,
|
||||
"domains": domains, "projects": projects,
|
||||
"tab": tab, "tab_data": tab_data,
|
||||
"all_contacts": all_contacts, "all_decisions": all_decisions,
|
||||
"counts": counts,
|
||||
"page_title": item["title"], "active_nav": "meetings",
|
||||
})
|
||||
|
||||
@@ -325,6 +354,31 @@ async def create_action_item(
|
||||
return RedirectResponse(url=f"/meetings/{meeting_id}", status_code=303)
|
||||
|
||||
|
||||
# ---- Decision linking ----
|
||||
|
||||
@router.post("/{meeting_id}/decisions/add")
|
||||
async def add_decision(
|
||||
meeting_id: str,
|
||||
decision_id: str = Form(...),
|
||||
db: AsyncSession = Depends(get_db),
|
||||
):
|
||||
await db.execute(text("""
|
||||
UPDATE decisions SET meeting_id = :mid WHERE id = :did
|
||||
"""), {"mid": meeting_id, "did": decision_id})
|
||||
return RedirectResponse(url=f"/meetings/{meeting_id}?tab=decisions", status_code=303)
|
||||
|
||||
|
||||
@router.post("/{meeting_id}/decisions/{decision_id}/remove")
|
||||
async def remove_decision(
|
||||
meeting_id: str, decision_id: str,
|
||||
db: AsyncSession = Depends(get_db),
|
||||
):
|
||||
await db.execute(text("""
|
||||
UPDATE decisions SET meeting_id = NULL WHERE id = :did AND meeting_id = :mid
|
||||
"""), {"did": decision_id, "mid": meeting_id})
|
||||
return RedirectResponse(url=f"/meetings/{meeting_id}?tab=decisions", status_code=303)
|
||||
|
||||
|
||||
# ---- Contact linking ----
|
||||
|
||||
@router.post("/{meeting_id}/contacts/add")
|
||||
|
||||
Reference in New Issue
Block a user