feat(phase-9): email dispatcher — HTML templates, delivery log, test endpoint
Backend: - app/models/email_log.py: EmailLog table (school_id, to, subject, type, status, error, sent_at) with EmailType + EmailStatus enums - migrations/002_phase9_email_logs.py: Alembic migration for email_logs table - app/templates/email/: 6 Jinja2 HTML templates — base layout, invoice, low_credit, license_expiry, overdue_warning, suspension - app/services/email.py: enhanced send_email() — accepts template_name+context for HTML rendering, logs every attempt to email_logs, retries up to 3x on transient SMTP failure with exponential backoff - app/routers/email.py: GET /api/email/logs (paginated, filterable by type/status/school), POST /api/email/test (send test email, super admin) - tasks/billing.py: invoice + overdue warning + suspension emails now use HTML templates - tasks/sms.py: low credit alert now uses HTML template - tasks/license.py: expiry warning now uses HTML template - app/main.py + migrations/env.py: wire in email_log model + email router Frontend: - EmailLogsPage.vue: table with to/subject/type badge/status badge/sent_at/error, type+status filters, pagination, Send Test Email modal - router/index.ts: /email-logs route - AppSidebar.vue: Email Logs nav item - api.ts: getEmailLogs, sendTestEmail
This commit is contained in:
32
backend/app/templates/email/suspension.html
Normal file
32
backend/app/templates/email/suspension.html
Normal file
@@ -0,0 +1,32 @@
|
||||
{% extends "email/base.html" %}
|
||||
{% block content %}
|
||||
<h2>Account Suspended</h2>
|
||||
<p>Dear {{ contact_name }},</p>
|
||||
|
||||
<div class="alert-red">
|
||||
<strong>Your TapTrack account for {{ school_name }} has been suspended due to an unpaid invoice.</strong>
|
||||
</div>
|
||||
|
||||
<div class="info-box">
|
||||
<div class="row"><span class="label">School</span><span class="value">{{ school_name }}</span></div>
|
||||
<div class="row"><span class="label">Invoice</span><span class="value">{{ invoice_number }}</span></div>
|
||||
<div class="row"><span class="label">Amount</span><span class="value">PHP {{ amount }}</span></div>
|
||||
<div class="row"><span class="label">Original Due Date</span><span class="value">{{ due_date }}</span></div>
|
||||
</div>
|
||||
|
||||
<p>The following services are now <strong>disabled</strong>:</p>
|
||||
<ul style="margin:8px 0 16px;padding-left:20px;color:#334155">
|
||||
<li>SMS notifications to parents and guardians</li>
|
||||
<li>Automated monthly reports</li>
|
||||
<li>License validation (on-prem may enter warning mode)</li>
|
||||
</ul>
|
||||
|
||||
<p>Attendance recording on your on-prem TapTrack instance continues to function.</p>
|
||||
|
||||
<p>To restore full service, please settle the overdue invoice immediately and contact us at
|
||||
<a href="mailto:support@taptrack.io">support@taptrack.io</a> to lift the suspension.</p>
|
||||
|
||||
<p><a class="btn" style="background:#dc2626" href="mailto:support@taptrack.io?subject=Account Suspension — {{ school_name }}">Contact Support to Restore</a></p>
|
||||
|
||||
<p>Thank you,<br><strong>TapTrack Hub Team</strong></p>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user