feat(audit): implement institutional audit logging for logins and system operations v3.4.8
This commit is contained in:
@@ -23,3 +23,19 @@ class AuditLog(db.Model):
|
||||
|
||||
def __repr__(self):
|
||||
return f"<AuditLog #{self.id} {self.action} on {self.module} by {self.user_email or 'System'}>"
|
||||
|
||||
def to_dict(self):
|
||||
"""Serializa el registro de auditoría a diccionario JSON."""
|
||||
return {
|
||||
'id': self.id,
|
||||
'user_id': self.user_id,
|
||||
'user_email': self.user_email,
|
||||
'action': self.action,
|
||||
'module': self.module,
|
||||
'entity_id': self.entity_id,
|
||||
'details': self.details,
|
||||
'ip_address': self.ip_address,
|
||||
'created_at': self.created_at.strftime('%Y-%m-%d %H:%M:%S') if self.created_at else None,
|
||||
'created_at_iso': self.created_at.isoformat() if self.created_at else None
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user