Enhance tenant context handling: add tenant database information to version injection and update navbar to display active tenant
This commit is contained in:
+12
@@ -76,6 +76,7 @@ from data_protection import (
|
|||||||
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||||
import settings as cfg
|
import settings as cfg
|
||||||
from settings import MongoClient
|
from settings import MongoClient
|
||||||
|
from tenant import get_tenant_context
|
||||||
|
|
||||||
|
|
||||||
app = Flask(__name__, static_folder='static') # Correctly set static folder
|
app = Flask(__name__, static_folder='static') # Correctly set static folder
|
||||||
@@ -1092,6 +1093,15 @@ def inject_version():
|
|||||||
client.close()
|
client.close()
|
||||||
|
|
||||||
current_module = _get_current_module(request.path)
|
current_module = _get_current_module(request.path)
|
||||||
|
current_tenant_db = MONGODB_DB
|
||||||
|
current_tenant_id = None
|
||||||
|
try:
|
||||||
|
ctx = get_tenant_context()
|
||||||
|
if ctx:
|
||||||
|
current_tenant_db = ctx.db_name or current_tenant_db
|
||||||
|
current_tenant_id = ctx.tenant_id
|
||||||
|
except Exception:
|
||||||
|
current_tenant_db = MONGODB_DB
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'APP_VERSION': APP_VERSION,
|
'APP_VERSION': APP_VERSION,
|
||||||
@@ -1104,6 +1114,8 @@ def inject_version():
|
|||||||
'is_admin': is_admin,
|
'is_admin': is_admin,
|
||||||
'unread_notification_count': unread_notification_count,
|
'unread_notification_count': unread_notification_count,
|
||||||
'current_permissions': current_permissions,
|
'current_permissions': current_permissions,
|
||||||
|
'current_tenant_db': current_tenant_db,
|
||||||
|
'current_tenant_id': current_tenant_id,
|
||||||
'permission_action_options': PERMISSION_ACTION_OPTIONS,
|
'permission_action_options': PERMISSION_ACTION_OPTIONS,
|
||||||
'permission_page_options': PERMISSION_PAGE_OPTIONS,
|
'permission_page_options': PERMISSION_PAGE_OPTIONS,
|
||||||
'permission_presets': us.get_permission_preset_definitions(),
|
'permission_presets': us.get_permission_preset_definitions(),
|
||||||
|
|||||||
+15
-1
@@ -191,6 +191,17 @@
|
|||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.navbar-text.tenant-badge {
|
||||||
|
font-size: 0.82rem;
|
||||||
|
color: rgba(255,255,255,0.9);
|
||||||
|
background: rgba(255,255,255,0.12);
|
||||||
|
border: 1px solid rgba(255,255,255,0.18);
|
||||||
|
padding: 0.25rem 0.55rem;
|
||||||
|
border-radius: 999px;
|
||||||
|
white-space: nowrap;
|
||||||
|
margin-right: 0.75rem;
|
||||||
|
}
|
||||||
|
|
||||||
.navbar-brand::before {
|
.navbar-brand::before {
|
||||||
content: attr(data-icon);
|
content: attr(data-icon);
|
||||||
@@ -1113,7 +1124,10 @@
|
|||||||
<button class="function-search-btn" type="submit">Los</button>
|
<button class="function-search-btn" type="submit">Los</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<span class="navbar-text text-light me-3">{{ session['username'] }}</span>
|
{% if current_tenant_db %}
|
||||||
|
<span class="navbar-text tenant-badge" title="Aktive Tenant-Datenbank">{{ current_tenant_db }}</span>
|
||||||
|
{% endif %}
|
||||||
|
<span class="navbar-text text-light me-3">{{ session['username'] }}</span>
|
||||||
<div class="dropdown me-2 user-menu-wrap">
|
<div class="dropdown me-2 user-menu-wrap">
|
||||||
<button class="btn btn-secondary dropdown-toggle user-menu-btn" type="button" id="invUserMenuDropdown" data-bs-toggle="dropdown" aria-expanded="false" data-notification-button="true">
|
<button class="btn btn-secondary dropdown-toggle user-menu-btn" type="button" id="invUserMenuDropdown" data-bs-toggle="dropdown" aria-expanded="false" data-notification-button="true">
|
||||||
👤
|
👤
|
||||||
|
|||||||
Reference in New Issue
Block a user