27 lines
569 B
Python
27 lines
569 B
Python
from datetime import datetime
|
|
from typing import Any
|
|
|
|
from ninja import Router, Schema
|
|
|
|
from apps.audit.models import OperationAuditLog
|
|
|
|
router = Router(tags=["audit"])
|
|
|
|
|
|
class OperationAuditLogOut(Schema):
|
|
id: int
|
|
module: str
|
|
action: str
|
|
target_type: str
|
|
target_id: str
|
|
request_snapshot: dict[str, Any]
|
|
result: str
|
|
ip_address: str | None
|
|
user_agent: str
|
|
created_at: datetime
|
|
|
|
|
|
@router.get("/operation-logs", response=list[OperationAuditLogOut])
|
|
def list_operation_logs(request):
|
|
return OperationAuditLog.objects.all()[:100]
|