Adds the admin backend foundation: AuditLog + Setting models/migration, an admin-only dashboard with KPI cards, and user management (search, ban/suspend/activate, tier override, trust adjust) with audit logging on every write action. Smoke suite extended to 64 checks.
15 lines
453 B
Python
15 lines
453 B
Python
"""Append-only audit trail writer for admin actions."""
|
|
from app.extensions import db
|
|
from app.models.audit import AuditLog
|
|
|
|
|
|
def log_action(actor, action: str, target_type: str, target_id, meta: dict | None = None):
|
|
"""Append an AuditLog row. Caller commits."""
|
|
db.session.add(AuditLog(
|
|
actor_id=actor.id if actor else None,
|
|
action=action,
|
|
target_type=target_type,
|
|
target_id=target_id,
|
|
meta=meta,
|
|
))
|