Files
breakpilot-compliance/backend-compliance/compliance/schemas/banner.py
T
Benjamin Admin 289ec5f396
Build + Deploy / build-admin-compliance (push) Successful in 2m28s
Build + Deploy / build-backend-compliance (push) Successful in 3m48s
Build + Deploy / build-ai-sdk (push) Failing after 45s
Build + Deploy / build-developer-portal (push) Successful in 1m28s
Build + Deploy / build-tts (push) Successful in 1m48s
Build + Deploy / build-document-crawler (push) Successful in 48s
Build + Deploy / build-dsms-gateway (push) Successful in 34s
Build + Deploy / build-dsms-node (push) Successful in 20s
CI / branch-name (push) Has been skipped
Build + Deploy / trigger-orca (push) Has been skipped
CI / guardrail-integrity (push) Has been skipped
CI / loc-budget (push) Failing after 24s
CI / secret-scan (push) Has been skipped
CI / go-lint (push) Has been skipped
CI / python-lint (push) Has been skipped
CI / nodejs-lint (push) Has been skipped
CI / nodejs-build (push) Successful in 3m1s
CI / dep-audit (push) Has been skipped
CI / sbom-scan (push) Has been skipped
CI / test-go (push) Failing after 49s
CI / test-python-backend (push) Successful in 45s
CI / test-python-document-crawler (push) Successful in 31s
CI / test-python-dsms-gateway (push) Successful in 27s
CI / validate-canonical-controls (push) Successful in 18s
feat(cmp): vendor-agnostic consent data model — 13 new fields
Extend banner consent records with consent_method, banner_version,
banner_config_hash, geo, page_url, referrer, device info, session_id
and consent_scope for full Art. 7 DSGVO proof with any tracking vendor.

Migration 107, backward-compatible (all fields nullable).
Admin detail modal shows tracking context, device info and technical data.
Fix pre-existing str|None → Optional[str] for Python 3.9 compat.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-05-10 23:12:20 +02:00

112 lines
3.1 KiB
Python

"""
Banner consent schemas — cookie consent SDK + admin configuration.
Phase 1 Step 4: extracted from ``compliance.api.banner_routes`` so the
route layer becomes thin delegation to ``compliance.services.banner_*``.
"""
from typing import Any, List, Optional
from pydantic import BaseModel, ConfigDict
class ConsentCreate(BaseModel):
"""Request body for recording a device consent."""
site_id: str
device_fingerprint: str
categories: List[str] = []
vendors: List[str] = []
ip_address: Optional[str] = None
user_agent: Optional[str] = None
consent_string: Optional[str] = None
# Vendor-agnostische Felder (Migration 107)
consent_method: Optional[str] = None
page_url: Optional[str] = None
referrer: Optional[str] = None
device_type: Optional[str] = None
browser: Optional[str] = None
os: Optional[str] = None
screen_resolution: Optional[str] = None
session_id: Optional[str] = None
consent_scope: Optional[str] = None
class SiteConfigCreate(BaseModel):
"""Request body for creating a banner site configuration."""
site_id: str
site_name: Optional[str] = None
site_url: Optional[str] = None
banner_title: Optional[str] = None
banner_description: Optional[str] = None
privacy_url: Optional[str] = None
imprint_url: Optional[str] = None
dsb_name: Optional[str] = None
dsb_email: Optional[str] = None
theme: Optional[dict[str, Any]] = None
tcf_enabled: bool = False
class SiteConfigUpdate(BaseModel):
"""Partial update for a banner site configuration."""
model_config = ConfigDict(extra="ignore")
site_name: Optional[str] = None
site_url: Optional[str] = None
banner_title: Optional[str] = None
banner_description: Optional[str] = None
privacy_url: Optional[str] = None
imprint_url: Optional[str] = None
dsb_name: Optional[str] = None
dsb_email: Optional[str] = None
theme: Optional[dict[str, Any]] = None
tcf_enabled: Optional[bool] = None
is_active: Optional[bool] = None
class CategoryConfigCreate(BaseModel):
"""Request body for adding a cookie category to a site."""
category_key: str
name_de: str
name_en: Optional[str] = None
description_de: Optional[str] = None
description_en: Optional[str] = None
is_required: bool = False
sort_order: int = 0
class VendorConfigCreate(BaseModel):
"""Request body for adding a vendor under a site's category."""
vendor_name: str
vendor_url: Optional[str] = None
category_key: str
description_de: Optional[str] = None
description_en: Optional[str] = None
cookie_names: List[str] = []
retention_days: int = 365
class LinkEmailRequest(BaseModel):
"""Request body for linking an email to a device fingerprint."""
site_id: str
device_fingerprint: str
email: str
class ConsentSyncRequest(BaseModel):
"""Request body for syncing banner consent to Einwilligungen."""
site_id: str
device_fingerprint: str
email: str
__all__ = [
"ConsentCreate",
"SiteConfigCreate",
"SiteConfigUpdate",
"CategoryConfigCreate",
"VendorConfigCreate",
"LinkEmailRequest",
"ConsentSyncRequest",
]