141 lines
4.1 KiB
Python
141 lines
4.1 KiB
Python
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
from govoplan_core.core.access import (
|
|
CAPABILITY_AUTH_PERMISSION_EVALUATOR,
|
|
CAPABILITY_AUTH_PRINCIPAL_RESOLVER,
|
|
)
|
|
from govoplan_core.core.module_guards import (
|
|
drop_table_retirement_provider,
|
|
persistent_table_uninstall_guard,
|
|
)
|
|
from govoplan_core.core.policy import (
|
|
CAPABILITY_POLICY_DEFINITION_GOVERNANCE,
|
|
CAPABILITY_POLICY_PRIVACY_RETENTION,
|
|
CAPABILITY_POLICY_SCHEDULING_PARTICIPANT_PRIVACY,
|
|
)
|
|
from govoplan_core.core.modules import (
|
|
FrontendModule,
|
|
MigrationSpec,
|
|
ModuleContext,
|
|
ModuleInterfaceProvider,
|
|
ModuleManifest,
|
|
)
|
|
from govoplan_core.core.views import ViewSurface
|
|
from govoplan_core.db.base import Base
|
|
from govoplan_policy.backend.db import models as policy_models
|
|
|
|
|
|
def _route_factory(context: ModuleContext):
|
|
del context
|
|
from govoplan_policy.backend.api.v1.routes import router
|
|
|
|
return router
|
|
|
|
|
|
def _privacy_retention_service(context: ModuleContext) -> object:
|
|
del context
|
|
from govoplan_policy.backend.retention import SqlPrivacyRetentionService
|
|
|
|
return SqlPrivacyRetentionService()
|
|
|
|
|
|
def _scheduling_participant_privacy_policy(context: ModuleContext) -> object:
|
|
del context
|
|
from govoplan_policy.backend.scheduling_privacy import (
|
|
SqlSchedulingParticipantPrivacyPolicy,
|
|
)
|
|
|
|
return SqlSchedulingParticipantPrivacyPolicy()
|
|
|
|
|
|
def _definition_governance_policy(context: ModuleContext) -> object:
|
|
del context
|
|
from govoplan_policy.backend.definition_governance import (
|
|
DefinitionGovernancePolicyProvider,
|
|
)
|
|
|
|
return DefinitionGovernancePolicyProvider()
|
|
|
|
|
|
manifest = ModuleManifest(
|
|
id="policy",
|
|
name="Policy",
|
|
version="0.1.9",
|
|
required_capabilities=(
|
|
CAPABILITY_AUTH_PRINCIPAL_RESOLVER,
|
|
CAPABILITY_AUTH_PERMISSION_EVALUATOR,
|
|
),
|
|
provides_interfaces=(
|
|
ModuleInterfaceProvider(
|
|
name="policy.definition_governance",
|
|
version="0.1.0",
|
|
),
|
|
),
|
|
route_factory=_route_factory,
|
|
migration_spec=MigrationSpec(
|
|
module_id="policy",
|
|
metadata=Base.metadata,
|
|
script_location=str(Path(__file__).with_name("migrations") / "versions"),
|
|
retirement_supported=True,
|
|
retirement_provider=drop_table_retirement_provider(
|
|
policy_models.PolicyOverride,
|
|
label="Policy overrides",
|
|
),
|
|
retirement_notes=(
|
|
"Destructive retirement removes explicit definition and View "
|
|
"policy overrides after a database snapshot."
|
|
),
|
|
),
|
|
uninstall_guard_providers=(
|
|
persistent_table_uninstall_guard(
|
|
policy_models.PolicyOverride,
|
|
label="Policy overrides",
|
|
),
|
|
),
|
|
frontend=FrontendModule(
|
|
module_id="policy",
|
|
package_name="@govoplan/policy-webui",
|
|
view_surfaces=(
|
|
ViewSurface(
|
|
id="policy.admin.system-retention",
|
|
module_id="policy",
|
|
kind="section",
|
|
label="System retention",
|
|
order=80,
|
|
),
|
|
ViewSurface(
|
|
id="policy.admin.tenant-retention",
|
|
module_id="policy",
|
|
kind="section",
|
|
label="Tenant retention",
|
|
order=80,
|
|
),
|
|
ViewSurface(
|
|
id="policy.admin.group-retention",
|
|
module_id="policy",
|
|
kind="section",
|
|
label="Group retention",
|
|
order=80,
|
|
),
|
|
ViewSurface(
|
|
id="policy.admin.user-retention",
|
|
module_id="policy",
|
|
kind="section",
|
|
label="User retention",
|
|
order=80,
|
|
),
|
|
),
|
|
),
|
|
capability_factories={
|
|
CAPABILITY_POLICY_DEFINITION_GOVERNANCE: _definition_governance_policy,
|
|
CAPABILITY_POLICY_PRIVACY_RETENTION: _privacy_retention_service,
|
|
CAPABILITY_POLICY_SCHEDULING_PARTICIPANT_PRIVACY: _scheduling_participant_privacy_policy,
|
|
},
|
|
)
|
|
|
|
|
|
def get_manifest() -> ModuleManifest:
|
|
return manifest
|