opencode ergebnis V0.1
This commit is contained in:
1 parent
61d86a3d83
commit
7e498ebc3f
71 files changed
+28982
-46
No files matched your search
@@ -0,0 +1,39 @@
|
||||
"""
|
||||
Hilfsfunktionen für CMBNet
|
||||
"""
|
||||
from flask import g
|
||||
import json
|
||||
|
||||
|
||||
def get_tenant_id():
|
||||
"""Gibt die aktuelle Tenant-ID aus dem Request-Kontext zurück"""
|
||||
return getattr(g, 'tenant_id', None)
|
||||
|
||||
|
||||
def get_current_account():
|
||||
"""Gibt den aktuellen Account aus dem Request-Kontext zurück"""
|
||||
return getattr(g, 'current_account', None)
|
||||
|
||||
|
||||
def log_transaction(action, entity_type, entity_id, details=None):
|
||||
"""
|
||||
Schreibt einen Eintrag ins Transaktionslog
|
||||
"""
|
||||
from cmbnet.db import get_db
|
||||
from cmbnet.core.logging import write_transaction_log
|
||||
|
||||
db = get_db()
|
||||
tenant_id = get_tenant_id()
|
||||
account = get_current_account()
|
||||
actor_id = account['id'] if account else None
|
||||
|
||||
details_json = json.dumps(details) if details else None
|
||||
|
||||
db.execute(
|
||||
'INSERT INTO transaction_log (tenant_id, actor_account_id, action, entity_type, entity_id, details) VALUES (?, ?, ?, ?, ?, ?)',
|
||||
(tenant_id, actor_id, action, entity_type, entity_id, details_json)
|
||||
)
|
||||
db.commit()
|
||||
|
||||
# Auch ins Logfile schreiben
|
||||
write_transaction_log(tenant_id, actor_id, account['name'] if account else None, action, entity_type, entity_id, details)
|
||||
Reference in new issue
Block a user