first commit

This commit is contained in:
Mateusz Gruszczyński
2026-03-13 15:17:32 +01:00
commit 986ffb200a
91 changed files with 4423 additions and 0 deletions

20
app/services/audit.py Normal file
View File

@@ -0,0 +1,20 @@
from __future__ import annotations
import json
from flask_login import current_user
from ..extensions import db
from ..models import AuditLog
def log_action(action: str, target_type: str = '', target_id: str = '', **details) -> None:
user_id = current_user.id if getattr(current_user, 'is_authenticated', False) else None
entry = AuditLog(
user_id=user_id,
action=action,
target_type=target_type,
target_id=str(target_id or ''),
details=json.dumps(details, ensure_ascii=False) if details else '',
)
db.session.add(entry)