Phase 10: Support Ticket System
Status: Not started Depends on: Phase 9 (Email Dispatcher — for email notifications)
Goal
Polish and harden the existing ticket system with SLA tracking display, email notifications on ticket create/reply, priority auto-escalation, and ticket assignment.
Planned Scope
Backend
Email notifications (using Phase 9 HTML templates)
- New ticket created → email to super admin(s)
- Super admin replies → email to school admin
- School admin replies → email to super admin(s)
- Template:
ticket_notification.html
SLA display
first_response_atalready stored — compute SLA status in list endpoint:sla_status:on_track|at_risk(>24h no response) |breached(>48h no response)
- Add
sla_statusto ticket list response
Priority auto-escalation (new Celery task tickets.escalate_stale)
- Scheduled every hour
- Tickets open > 48h with
priority = normal→ setpriority = high - Tickets open > 72h with no reply → set
priority = urgent
Ticket assignment
assigned_to: str | Nonecolumn already on modelPUT /api/tickets/{id}already acceptsassigned_to- Add
GET /api/users?role=super_adminfilter for assignee picker
Bulk actions
POST /api/tickets/bulk-close— close list of resolved ticket IDs (super admin)
Frontend
TicketsPage.vue — super admin view enhancements
- SLA status column (green/amber/red badge)
- Assignee column + inline assign dropdown
- Priority badge
- Bulk close: checkbox selection + "Close Selected" button
- Status filter tabs (All / Open / In Progress / Resolved / Closed)
TicketDetailPage.vue — enhancements
- Assignee selector
- Priority selector
- SLA timer display (hours since opened, color-coded)
- Internal notes clearly marked with lock icon (super admin only)
worker.py — add tickets.escalate_stale to beat schedule (every hour)
Key Files to Modify
backend/app/routers/tickets.py— SLA status in response, bulk-close endpointbackend/app/tasks/tickets.py(new) — escalate_stale taskbackend/app/worker.py— add escalation task to beat schedulebackend/app/templates/email/ticket_notification.html(new)frontend/src/pages/TicketsPage.vue— SLA, assign, bulk closefrontend/src/pages/TicketDetailPage.vue— SLA timer, assign, priorityfrontend/src/lib/api.ts— bulkCloseTickets