Preserve tenant module entitlement state

This commit is contained in:
2026-08-04 08:21:50 +02:00
parent d4bfc6e45a
commit e3c18f9aa8
4 changed files with 36 additions and 2 deletions
@@ -18,6 +18,7 @@ from govoplan_core.core.access import (
TenantContextSwitcher,
)
from govoplan_core.core.change_sequence import ChangeSequenceEntry, decode_sequence_watermark, encode_sequence_watermark, record_change, sequence_watermark_is_expired
from govoplan_core.core.module_entitlements import MODULE_ENTITLEMENTS_KEY
from govoplan_core.core.principal_cache import invalidate_auth_principals
from govoplan_core.core.runtime import get_registry
from govoplan_core.db.session import get_session
@@ -667,7 +668,14 @@ def _apply_tenant_content_updates(tenant: Tenant, payload: TenantUpdateRequest)
if payload.default_locale is not None:
tenant.default_locale = _normalized_tenant_locale(payload.default_locale)
if payload.settings is not None:
tenant.settings = payload.settings
current_settings = dict(tenant.settings or {})
next_settings = dict(payload.settings)
next_settings.pop(MODULE_ENTITLEMENTS_KEY, None)
if MODULE_ENTITLEMENTS_KEY in current_settings:
next_settings[MODULE_ENTITLEMENTS_KEY] = current_settings[
MODULE_ENTITLEMENTS_KEY
]
tenant.settings = next_settings
def _normalized_optional_text(value: str | None) -> str | None: