API and persisted records use PowerOnModel system fields: - sysCreatedAt, sysCreatedBy, sysModifiedAt, sysModifiedBy Removed legacy JSON/DB field names: - _createdAt, _createdBy, _modifiedAt, _modifiedBy Frontend (frontend_nyla) and gateway call sites were updated accordingly. Database: - Bootstrap runs idempotent backfill (_migrateSystemFieldColumns) from old underscore columns and selected business duplicates into sys* where sys* IS NULL. - Re-run app bootstrap against each PostgreSQL database after deploy. - Optional: DROP INDEX IF EXISTS "idx_invitation_createdby" if an old index remains; new index: idx_invitation_syscreatedby on Invitation(sysCreatedBy). Tests: - RBAC integration tests aligned with current GROUP mandate filter and UserMandate-based UserConnection GROUP clause; buildRbacWhereClause(..., mandateId=...) must be passed explicitly (same as production request context).
90 lines
3.6 KiB
Python
90 lines
3.6 KiB
Python
# Copyright (c) 2025 Patrick Motsch
|
|
# All rights reserved.
|
|
"""Feature models: Feature, FeatureInstance."""
|
|
|
|
import uuid
|
|
from typing import Optional, Dict, Any
|
|
from pydantic import BaseModel, Field
|
|
from modules.datamodels.datamodelBase import PowerOnModel
|
|
from modules.shared.attributeUtils import registerModelLabels
|
|
from modules.datamodels.datamodelUtils import TextMultilingual
|
|
|
|
|
|
class Feature(PowerOnModel):
|
|
"""
|
|
Feature-Definition (global, z.B. 'trustee', 'chatbot').
|
|
Features sind die verfügbaren Funktionalitäten der Plattform.
|
|
"""
|
|
code: str = Field(
|
|
description="Unique feature code (Primary Key), z.B. 'trustee', 'chatbot'",
|
|
json_schema_extra={"frontend_type": "text", "frontend_readonly": False, "frontend_required": True}
|
|
)
|
|
label: TextMultilingual = Field(
|
|
description="Feature label in multiple languages (I18n)",
|
|
json_schema_extra={"frontend_type": "multilingual", "frontend_readonly": False, "frontend_required": True}
|
|
)
|
|
icon: str = Field(
|
|
default="",
|
|
description="Icon identifier for the feature",
|
|
json_schema_extra={"frontend_type": "text", "frontend_readonly": False, "frontend_required": False}
|
|
)
|
|
|
|
|
|
registerModelLabels(
|
|
"Feature",
|
|
{"en": "Feature", "de": "Feature", "fr": "Fonctionnalité"},
|
|
{
|
|
"code": {"en": "Code", "de": "Code", "fr": "Code"},
|
|
"label": {"en": "Label", "de": "Bezeichnung", "fr": "Libellé"},
|
|
"icon": {"en": "Icon", "de": "Symbol", "fr": "Icône"},
|
|
},
|
|
)
|
|
|
|
|
|
class FeatureInstance(PowerOnModel):
|
|
"""
|
|
Instanz eines Features in einem Mandanten.
|
|
Ein Mandant kann mehrere Instanzen desselben Features haben.
|
|
"""
|
|
id: str = Field(
|
|
default_factory=lambda: str(uuid.uuid4()),
|
|
description="Unique ID of the feature instance",
|
|
json_schema_extra={"frontend_type": "text", "frontend_readonly": True, "frontend_required": False}
|
|
)
|
|
featureCode: str = Field(
|
|
description="FK → Feature.code",
|
|
json_schema_extra={"frontend_type": "select", "frontend_readonly": True, "frontend_required": True}
|
|
)
|
|
mandateId: str = Field(
|
|
description="FK → Mandate.id (CASCADE DELETE)",
|
|
json_schema_extra={"frontend_type": "text", "frontend_readonly": True, "frontend_required": True}
|
|
)
|
|
label: str = Field(
|
|
default="",
|
|
description="Instance label, z.B. 'Buchhaltung 2025'",
|
|
json_schema_extra={"frontend_type": "text", "frontend_readonly": False, "frontend_required": True}
|
|
)
|
|
enabled: bool = Field(
|
|
default=True,
|
|
description="Whether this feature instance is enabled",
|
|
json_schema_extra={"frontend_type": "checkbox", "frontend_readonly": False, "frontend_required": False}
|
|
)
|
|
config: Optional[Dict[str, Any]] = Field(
|
|
default=None,
|
|
description="Instance-specific configuration (JSONB). Structure depends on featureCode.",
|
|
json_schema_extra={"frontend_type": "json", "frontend_readonly": False, "frontend_required": False}
|
|
)
|
|
|
|
|
|
registerModelLabels(
|
|
"FeatureInstance",
|
|
{"en": "Feature Instance", "de": "Feature-Instanz", "fr": "Instance de fonctionnalité"},
|
|
{
|
|
"id": {"en": "ID", "de": "ID", "fr": "ID"},
|
|
"featureCode": {"en": "Feature", "de": "Feature", "fr": "Fonctionnalité"},
|
|
"mandateId": {"en": "Mandate", "de": "Mandant", "fr": "Mandat"},
|
|
"label": {"en": "Label", "de": "Bezeichnung", "fr": "Libellé"},
|
|
"enabled": {"en": "Enabled", "de": "Aktiviert", "fr": "Activé"},
|
|
"config": {"en": "Configuration", "de": "Konfiguration", "fr": "Configuration"},
|
|
},
|
|
)
|