Some checks failed
CI / go-lint (push) Has been skipped
CI / python-lint (push) Has been skipped
CI / nodejs-lint (push) Has been skipped
CI / test-go-ai-compliance (push) Failing after 30s
CI / test-python-backend-compliance (push) Successful in 30s
CI / test-python-document-crawler (push) Successful in 21s
CI / test-python-dsms-gateway (push) Successful in 17s
- Ruff: 144 auto-fixes (unused imports, == None → is None), F821/F811/F841 manuell - CVEs: python-multipart>=0.0.22, weasyprint>=68.0, pillow>=12.1.1, npm audit fix (0 vulns) - TS: 5 tote Drafting-Engine-Dateien entfernt, allowed-facts/sanitizer/StepHeader/context fixes - Tests: +104 (ISMS 58, Evidence 18, VVT 14, Generation 14) → 1449 passed - Refactoring: collect_ci_evidence (F→A), row_to_response (E→A), extract_requirements (E→A) - Dead Code: pca-platform, 7 Go-Handler, dsr_api.py, duplicate Schemas entfernt Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
89 lines
3.0 KiB
Python
89 lines
3.0 KiB
Python
"""
|
|
SQLAlchemy models for Legal Documents Extension.
|
|
|
|
Tables:
|
|
- compliance_user_consents: End-User Consent-Records
|
|
- compliance_consent_audit_log: Immutable Audit-Trail
|
|
- compliance_cookie_categories: Cookie-Kategorien fuer Banner
|
|
"""
|
|
|
|
import uuid
|
|
from datetime import datetime
|
|
|
|
from sqlalchemy import (
|
|
Column, Text, Boolean, Integer, DateTime, Index, JSON
|
|
)
|
|
from sqlalchemy.dialects.postgresql import UUID
|
|
|
|
from classroom_engine.database import Base
|
|
|
|
|
|
class UserConsentDB(Base):
|
|
"""End-User Consent-Record fuer rechtliche Dokumente."""
|
|
|
|
__tablename__ = 'compliance_user_consents'
|
|
|
|
id = Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
|
|
tenant_id = Column(UUID(as_uuid=True), nullable=False)
|
|
user_id = Column(Text, nullable=False)
|
|
document_id = Column(UUID(as_uuid=True), nullable=False)
|
|
document_version_id = Column(UUID(as_uuid=True))
|
|
document_type = Column(Text, nullable=False)
|
|
consented = Column(Boolean, nullable=False, default=True)
|
|
ip_address = Column(Text)
|
|
user_agent = Column(Text)
|
|
consented_at = Column(DateTime, nullable=False, default=datetime.utcnow)
|
|
withdrawn_at = Column(DateTime)
|
|
created_at = Column(DateTime, nullable=False, default=datetime.utcnow)
|
|
|
|
__table_args__ = (
|
|
Index('idx_user_consents_tenant', 'tenant_id'),
|
|
Index('idx_user_consents_user', 'user_id'),
|
|
Index('idx_user_consents_doc', 'document_id'),
|
|
Index('idx_user_consents_type', 'document_type'),
|
|
)
|
|
|
|
|
|
class ConsentAuditLogDB(Base):
|
|
"""Immutable Audit-Trail fuer Consent-Aktionen."""
|
|
|
|
__tablename__ = 'compliance_consent_audit_log'
|
|
|
|
id = Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
|
|
tenant_id = Column(UUID(as_uuid=True), nullable=False)
|
|
action = Column(Text, nullable=False)
|
|
entity_type = Column(Text, nullable=False)
|
|
entity_id = Column(UUID(as_uuid=True))
|
|
user_id = Column(Text)
|
|
details = Column(JSON, default=dict)
|
|
ip_address = Column(Text)
|
|
created_at = Column(DateTime, nullable=False, default=datetime.utcnow)
|
|
|
|
__table_args__ = (
|
|
Index('idx_consent_audit_tenant', 'tenant_id'),
|
|
Index('idx_consent_audit_action', 'action'),
|
|
Index('idx_consent_audit_created', 'created_at'),
|
|
)
|
|
|
|
|
|
class CookieCategoryDB(Base):
|
|
"""Cookie-Kategorien fuer Consent-Banner."""
|
|
|
|
__tablename__ = 'compliance_cookie_categories'
|
|
|
|
id = Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
|
|
tenant_id = Column(UUID(as_uuid=True), nullable=False)
|
|
name_de = Column(Text, nullable=False)
|
|
name_en = Column(Text)
|
|
description_de = Column(Text)
|
|
description_en = Column(Text)
|
|
is_required = Column(Boolean, nullable=False, default=False)
|
|
sort_order = Column(Integer, nullable=False, default=0)
|
|
is_active = Column(Boolean, nullable=False, default=True)
|
|
created_at = Column(DateTime, nullable=False, default=datetime.utcnow)
|
|
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
|
|
|
|
__table_args__ = (
|
|
Index('idx_cookie_cats_tenant', 'tenant_id'),
|
|
)
|